Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Variables And Initial Values


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
three()
three()
End Sub

Sub Three()
Dim num As Double
lstresults.Items.Add(num)
num = 3
End Sub

When i run it i get the following in the list box:
0
0



can some1 explain to me why?
thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Retaining Initial Values
Hi,

I have a small problem that I can't seem to get around. I have a usercontrol that requires 4 variables to have preset intial values. I tried defining them as static variables in the usercontrol intialize sub, but once it reaches my sub that I am working in those values are destroyed. I tried delcaring in the main form as well as public and static, but the values never reach my sub. How can I get around htis? Thanks in advance!

Initial Values In Userform From Bookmarks
Hi all, I have created a userform for printing different pages of a word doc depending on which control the user selects. Now I'm trying to imporove this userform by setting initial values to the controls depending on different bookmarks in the word document. (The user shouldn't have to select this unless he doesn't want the default value.)

I got 3 controls in the userform named optAvtalLR optAvtalTB and optArb and my mission is this... if bookmarkLR = "x" then optAvtalLR = true elseif bookmarkTB="x" then optavtalTB=true else optArb = true

I can't get it to work properly I have tried several ways to write this code but no success... When bookmarkLR = x the userform is initialized ok and the optAvtalLR is checked ok, but when bookmarkLR doesn't exist and/or bookmarkTB = x the userform is not initialized at all ???

Can anyone help me out here? How should I write the userform_initialize code?
/Thanks
Carina

Populating An Array With Initial Values
Does anybody know how I can assign a lot of values to an array at once?

in C I would do some thing like
int MyData[] = {1,1,2,3,7}

is there any way I can do something similar in VB?

Option Button And Initial Values (RESOLVED)
I have an array of option buttons which set various constants values.
The problem is that when I open the form, although I can set my default option button to have value = true, i.e. so that it is selected, it does not automatically operate. I currently have to manually select an option button for it to work.




Edited by - jimvt on 6/20/2004 2:23:52 AM

Trying To Split First Initial, Middle Initial, And Last Name/Suffix With Excel Macro
Hi,

I am a Data analyst for a average-sized pharmaceutical company. I have been assigned the task of creating a macro the separates names. I could use Text to columns on the column of names that need to be separated, but I only need the space before the last name to be separated. So, in Column A would be the Full name(ex: J H williams III). In column B, the first an second initials would be located(ex: J H). The last name and suffix would be in the Column C. When I record a macro and use Text to Columns, I find that I can't specify for the macro to skip to the last name(basically the next word with 2 or more letters) and split there. Does anyone have a macro that can do this. Below is an example of how the data looks and how I need it to work.


K R Russell IV

The data needs to be split into columns on the same row

K R in Column B

&

Russell IV in column C


Any help would be appreciated.

Dameon

Getting Values Of OS Variables
Hello,
I'm looking for the most right method to get the values of OS variables, like 'windir', 'temp' etc.
I know I can do it by running a shell that getting output of 'set' or 'echo %TEMP%', but I guess that VB can offer me a better method for it, but I don't know how..

Thanks!!

Cell Values As Variables
I`m hoping someone can help me with this.

Looking to do the following :

User clicks a cell, cell value stored as variable. If user changes cell vale, variable pasted into a cell and the new cell value is pasted next to it.

Can anyone help or point me in the right direction ?

Regards,

Variables Not Holding Values
hello again,

im transferring a fortran program to VB, and the translator doesnt do great but it does its job. Anyway I have a huge list of public variables, these variables are set right at the beginning of the program (they are specifically set to zero). then the program calls a subroutine and then the subroutine calls another subroutine. When I check the variables some of the variables are coming in as zeros and others (that are set to zero) are coming in "empty".

Is it possible for something in the program to unset them?

Can you set the value of the public variables in the public statements?

Does setting the values in the main program possible effect the way they are transfered to different subroutines since they are public variables?

thanks guys.

Using Array Values To Set Variables
Hi,

sorry I know the title is not all to clear, but here's my problem:

I have an array (variant) with -- say -- 10 values. These values also happen to be the names of 10 variables (boolean).

To make it clear:

array(Var1, Var2, Var3, ... , Var10).
and 10 boolean variables called Var1, Var2, ...

Now, I'd like to assign to each of the Var# a value, but not manually (in fact I got 180 of them, and the value depends on many other variables' values)

So what I'd like to do is to loop through the array elements, and use them to set the boolean Var# values.

To summarize, rather than stating Var1 = True I'd like to do something like array(1) = True.

the problem is that if I do that it will set the first element of the array to True, as opposed to the variable Var1.

Any suggestions?

thanks

roman

Evaluating Values In Variables
I am working on a table driven app. I have placed all of my Select and insert statements in an sql 7 DB table. Things seemed to be going great until I needed to do an insert using an insert statement stored in the table. I query the DB to get the insert statement, place the statement in a variable. The problem is that the insert statement refers to the .field(x) property of a recordset and when the insert statement is stored in the variable it stores ".Recordset.Field(x)" instead of the value of .recordset.field(x). How do I evaluate the insert statement or the contents of the variable the insert statement is stored in to reflect the value of the .field(x) property?

Storing Values In Variables
I am using a Microsoft Data access to access a database ...
I can get the values to go to a text box .. but how would i store the values into variables ..

Storing Values From Variables
Can anyone tell me how to store a value from a variable. I want my program to take same old values when it was ended last time.

Thanks in advance

Passing Values From DB To Variables
I know this code is wrong so HOW do I set the variables equal to what is in my database?

If Request.Form("txtName") <> "" Then
SQL = "Select * FROM Register WHERE " & "Register.userID='" & strUserID & _
"' AND Register.password ='" & strPassword & _
"' OR Register.FirstName ='" & strFirstName & _
"' OR Register.LastName ='" & strLastName & _
"' OR Register.Address ='" & strAddress & _
"' OR Register.State ='" & strState & _
"' OR Register.ZipCode ='" & strZipCode & _
"' OR Register.PhoneNumber ='" & strPhoneNumber & _
"' OR Register.Email ='" & strEmail & "'"

Variables Retaining Their Values...
Is it possible to make sure that variables can be emptied of contents within a procedure? Or rather, after one procedure is finished and the end-user restarts another procedure?

I have found that when I run two independant procedures, both using the same variables, that the older variables are remembered by VBA. This is highly annoying, because if the variable is supposed to be empty in the second procedure, I want VB and Excel to perform a different set of instructions.

Many thanks for any help!

----------------------------------------
| --== Alta Alatis Patent ==-- |
----------------------------------------

Global Variables And Clearing Values
Hi.. I am a newbie to VB6, only started 1 month ago. I have created a very simple program, that every time someone clicks on the command button the value in the label increases by 1. I just went one step further yesterday by adding a command button that will clear the label.

My problem is that when you click the command button to clear the label, and then you click on the command button to increase the value by 1, it picks up from where it left off, and not from 0, where I want it to start from.

Can someone help me out. Here is the code I have so far:


Dim increase As Integer
___________________________________
Private Sub cmdcompute_Click()
increase = increase + 1
lblincrease.Caption = increase
End Sub
___________________________________
Private Sub cmdclear_Click()
lblincrease.Caption = ""
End Sub

Also, I used the Global Variable in another more complicated program, and the same problem occurs, this time the program is used to calculate the total of fat, carbohydrate and protein calories. The user enters (in textboxes) the grams of fat, the grams of carbohydrate and the grams of protein. Each gram of fat is nine calories, whereas a gram of protein or carbohydrate in four calories.

The program displays the total calories for the current food item in a label. And in two other labels it displays the accumulated sum of the calories and a count of the items entered.

The problem with this program is that when I click the command button called Clear, it clears all the labels and text boxes, and then when I click on the command button calculate, the number of items continues on from where it left off, and not from 0. Here is the code for that program:
______________________________________
Dim numcount As Single
______________________________________
Private Sub cmdcalculate_Click()
Dim fat As Single
Dim protein As Single
Dim carb As Single
Dim sumcalorie As Single
Dim numcount2 As Single
numcount = numcount + 1
fat = Val(txtfat.Text) * 9
protein = Val(txtprotein.Text) * 4
carb = Val(txtcarb.Text) * 4
sumcalorie = fat + protein + carb
numcount2 = (fat + protein + carb) * numcount
lblcalories.Caption = sumcalorie
lblitem.Caption = numcount
lblsumcalorie.Caption = numcount2
End Sub
______________________________________
Private Sub cmdclear_Click()
txtcarb.Text = ""
txtfat.Text = ""
txtprotein.Text = ""
lblitem.Caption = ""
lblcalories.Caption = ""
lblsumcalorie.Caption = ""
End Sub

______________________________________
Private Sub cmdexit_Click()
End
End Sub
______________________________________
Private Sub cmdprint_Click()
Print
End Sub



Can someone help me out? I would really appreciate it. Thanks in advance.

Decimal Values Saved In Variables
Hi everyone,

I need a variable in my program that can store a decimal number containing two decimal places. What do I need to declare my variable as to use cDec()? Can some show a quick example?

Thanks thanks thanks

Helpme!! Calculating Values Using Variables.
hi i am having problems running this code. It is for a resturent program and was orginally from this site. It worked for my friend but not for me, can anyone please help.

declarations

Option Explicit
Dim Price As Single
Dim Total As Currency
Dim Quantity As Integer
Dim curtxts1tp As Currency
Dim curtxts2tp As Currency
Dim curtxts3tp As Currency
Dim curtxts4tp As Currency
Dim curtxtmc1tp As Currency
Dim curtxtmc2tp As Currency
Dim curtxtmc3tp As Currency
Dim curtxtmc4tp As Currency
Dim curtxtmc5tp As Currency
Dim curtxtmc6tp As Currency
Dim curtxtd1tp As Currency
Dim curtxtd2tp As Currency
Dim curtxtd3tp As Currency
Dim curtxtd4tp As Currency
Dim curtxtdr1tp As Currency
Dim curtxtdr2tp As Currency
Dim curtxtdr3tp As Currency
Dim curtxtdr4tp As Currency
Dim curtxtdr5tp As Currency
Dim curtxtdr6tp As Currency
Dim curtxtsn1tp As Currency
Dim curtxtsn2tp As Currency
Dim curtxtsn3tp As Currency
Const curVatv As Currency = 0.175
Const strFormat As String = "£#,##0.00"
Dim curvat As Currency
Dim curSubtotal As Currency
Dim curTotalCost As Currency

cmd button

Private Sub Cmdorder_Click()
curtxts1tp = CCur(txts1tp.Text)
curtxts2tp = CCur(txts2tp.Text)
curtxts3tp = CCur(txts3tp.Text)
curtxts4tp = CCur(txts4tp.Text)
curtxtmc1tp = CCur(txtmc1tp.Text)
curtxtmc2tp = CCur(txtmc2tp.Text)
curtxtmc3tp = CCur(txtmc3tp.Text)
curtxtmc4tp = CCur(txtmc4tp.Text)
curtxtmc5tp = CCur(txtmc5tp.Text)
curtxtmc6tp = CCur(txtmc6tp.Text)
curtxtd1tp = CCur(txtd1tp.Text)
curtxtd2tp = CCur(txtd2tp.Text)
curtxtd3tp = CCur(txtd3tp.Text)
curtxtd4tp = CCur(txtd4tp.Text)
curtxtdr1tp = CCur(txtdr1tp.Text)
curtxtdr2tp = CCur(txtdr2tp.Text)
curtxtdr3tp = CCur(txtdr3tp.Text)
curtxtdr4tp = CCur(txtdr4tp.Text)
curtxtdr5tp = CCur(txtdr5tp.Text)
curtxtdr6tp = CCur(txtdr6tp.Text)
curtxtsn1tp = CCur(txtsn1tp.Text)
curtxtsn2tp = CCur(txtsn2tp.Text)
curtxtsn3tp = CCur(txtsn3tp.Text)
txtVatv.Text = curVatv
curSubtotal = txtsubtotalv.Text
curTotalCost = txttotalv.Text





curSubtotal = (curtxts1tp + curtxts2tp + curtxts3tp + curtxts4tp + curtxtmc1tp + curtxtmc2tp + curtxtmc3tp + curtxtmc4tp + curtxtmc5tp + curtxtmc6tp + curtxtd1tp + curtxtd2tp + curtxtd3tp + curtxtd4tp + curtxtdr1tp + curtxtdr2tp + curtxtdr3tp + curtxtdr4tp + curtxtdr5tp + curtxtdr6tp + curtxtsn1tp + curtxtsn2tp + curtxtsn3tp)
'calculate vat
curvat = curVatv * curSubtotal
'calculate total
curTotalCost = curVatv + curSubtotal

'formats data and sends to textboxes
txtsubtotalv.Text = Format(curSubtotal, strFormat)
txtVatv.Text = Format(curvat, strFormat)
txttotalv.Text = Format(curTotalCost, strFormat)
End Sub

I get constant errors and runtime(13) mismatch errors, and i think it is down to the constant that i have declared (VAT Rate = 0.175) and then trying to change on the command button. Can Anyone help me put it right. I have to get this working by tommorrow so any help is greatly apprcieated. Thanks in advance.

How Do I Clear A Variables TYPE Values?
Hi, I have a large variable defined as a TYPE with approx 30 elements.

Is there an easy way to clear all the values without going thru each one?

Thanks

Can You Pass Values/variables Between Forms??
Thats it... thats my question

Combo Box Values As Variables In VBScript/SQL
Hi,

I posted this under a different forum, but I'm not sure if it was the right place.

Please redirect me if this is not the correct forum for this question.

This is actually quite a simple problem...

I have a form which enables users to search a database. Currently they can use a series of checkboxes and a text area.

I would like to incorporate a combo box in this form. The values would be hard-coded. The user selects an option, which is included in the SQL statement along with those from the other form elements.

I'm not sure how to get the values form the combo box into a variable...

There would be up to 40 values.

Can anyone show me how to do this?

Thanks very much, mM

Pass Values Of String Variables To A Sub
When I pass arguments to a sub, the sub takes the arguments literally and uses the string variable parameter as the input.
What I'm actually trying to pass is the value of the string variable.
Here's some of the code:

Private Sub txtParts_LostFocus()
Dim intAnswer As Integer
Dim dbs As Database
Dim rst As DAO.Recordset
Dim strPartName As String
Call something_lostfocus(strPartName, "tblpartsinfo", "llngzMaintEntryNoLink", "chrPartName", Me.txtEntryNo, "txtParts")

which then goes to the something_lostfocus sub code here:

On Error GoTo error_handler:
Dim intAnswer As Integer
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strTable, dbOpenTable)
With rst
    .Index = strIndexNo
    .Seek "=", varSeekVal
    strField = ![strTableFieldName]
    
    
    
    
    Debug.Print "Me." & strMeField
    'Me.txtParts

    
    If ("Me." & strMeField) <> strField Then
    intAnswer = MsgBox("Update existing data with this information?", vbQuestion + vbYesNo + vbDefaultButton2, "Motorhome Maintenance Records")
        If intAnswer = vbYes Then
            rst.Edit
            strTableFieldName = "Me." & strMeField
            .Update
        End If
    End If
End With
exit_procedure:

... and so on

the code in the sub has some errors in it because I have been troubleshooting but basically the problem will be for example:
this step: strField = ![strTableFieldName]
will result in strfield equalling !chrPartName

and NOT the value of the field !chrPartName in the associated table.  That's just the first of several examples where it doesn't work.

thanks for taking a look.

Access - Values From Tables To Variables
I'm trying to pull some values from a table and store them as variables in VB. I have a table, tblHistory, with three fields; partno, cust, matl. I'm trying to search for a part number and then record the values for that record. Here's the code I have so far:

Dim variable_storing_partno As Integer

variable_storing_partno = 1
variable_storing_cust = "dave"
variable_storing_matl = "wood"


Dim db As Database
Dim strSQL As String
Dim rs As Recordset



Set db = CurrentDb


strSQL = "SELECT * FROM tblHistory WHERE [partno] =" & variable_storing_partno

Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)


rs.AddNew
    rs("partno") = variable_storing_partno
    rs("cust") = variable_storing_cust
    rs("matl") = variable_storing_matl
rs.Update

Set rs = Nothing
Set db = Nothing
When I run it, I get a type mismatch error on the line "Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)". Anyone got any ideas? Thanks.

Assigning Default Values To Variables
Is there any way to assign a value to a variable at the time of declaring the variable.

I m declaring the variables in general decalrations section. I want to assign default value to these variables at the time of declaration itself.

How can I do it ?

Thanking in advance.

Accessing Values Of Variables In Another Form
I'm a beginner in vb.

I am trying to print the value of a global counter variable which I declared in my module. Form 1 manipulates and increments the value of my counter variable. However, when I view the value of the counter variable in Form 2, the value never increments. Why is this so?

How will form 2 be able to display the correct value of the counter variable which is manipulated and incremented in form 1?

Any help will be greatly appreciated! thanks in advance!

Passing Values To A Function Through Variables...
Hello,

Before I ask my question I'd quickly like to say that I'm just a lowly beginner, and... please don't eat me *cringes in fear*. Alright now that, that's is over...

I'm making a small text based RPG in VB 6 right now to test out what I know so far. I need to know if it is possible, after defining variables in the main form code and specifying their values, to use the variables in function arguments (and if so, how)?

Example:

Private Sub Form_Load()
Dim strname As String
Dim intUHP As Integer
Dim intUATK As Integer
Dim intUDEF As Integer

Dim strBum As String
Dim intBumHP As Integer
Dim intBumATK As Integer
Dim intBumDEF As Integer

End Sub
_______________________________________________

Public Function BTMAttack(UHP as Integer, UATK as Integer, UDEF as Integer, EHP as Integer, EATK as Integer, EDEF as Integer)

End Function
_____________________________________________

Private Sub cmdattack_Click()

Call BTMAttack(intUHP, intUATK, intUDEF, intBumHP, intBumATK, intBumDEF)

End Sub


Thanks for any help.

Passing Of Values From Webbrowser Component To Vb Variables
How can access data from a web browser component used in my vb application?

Declaring Variables In Excel VBA So The Values Stick
I'm encountering some confusion regarding just how to declare my variables to that they will retain their values. Currently I have several modules and I declare most of my variables as Public so they are available throughout. However I find Public variables get erased if I interrupt or debug a macro. I can't use Const and static variables don't seem to work either, that is when I reference a Static variable from another module, I get a compile error.

The Issue is I have several variables that reference specific worksheets (i.e. SanJoaquinCalc = ModelBook.Sheet("San Joaquin Calc") and the are used repeatedly throughout the project, but I would like to run one macro when the spreadsheet is opened to define the sheet name variables and then be done with it. Now I seem to have to run the SheetNames macro at the start of each macro that uses one of the sheet name variables, just to be sure it is defined.

Setting Double Variables To Null Values
I am writing an application which reads in data from a sql server database and outputs it to Excel.

I am dealing with mostly numeric data so a lot of my variables are defined as doubles. However... if the database contains Null, I cannot assign Null to a double, and my application outputs 0 to excel.

This is a problem because I need to distinguish Null values from 0 values.

Is there any alternative value I can set my variables to? The only way around this problem that I can see is to define everything as variant, and I don't really want to do that.

Thanks

Adding The Values Of Variables In The File Of Text
Hi all

How I can add the values of variables in file of text

for example.

I have 6 TextBoxes, in which are displayed there different the variables. I click on Command1 and a write it to file of text. Then im writing other the variables to these TextBoxes
And again Click on Command1 and I want to add this – how to make?

I want to be able to read in this TextBoxes all these total values

thanks in advance

Variables Or Database - Updating And Passing Values
A bit about the program
There are 3 price ranges for a product and the product can only fall into a price range if it meets the price ranges criteria. In this case the product dimension size.
(If x < 10 then price range A, If x >9 then price range B etc…)

The price ranges and there criteria needs to have the ability to be changed. – This will be done in a separate form.
My question to you is: Do I need to have a database backend to store the price ranges, or can I just pass them as variables?

Thanks Pete
PFWD.org.uk

Help With Initial
the code like

Code:

Private Sub Form_Load()
Dim num As Integer
num = 3
End Sub


when I use watch to view the value of num, it show the value is 0, why?

Initial Snapshot, Pt 2
HELP!! I STILL CAN NOT GET MY MERGE REPLICATION TO WORK.

I am trying to set up merge replication on my SQL Server db. I have set my machine up as Publisher/Distributor and the 'other' server as subscriber. I believe I have done everything including 'push' the subscription to the subscriber. The problem is that when I go into the Replication Folder under publications and look at the publication itself, it says that it's status is 'deactiviated.' Why did this happen and what can I do about it? I need to get this replication going. PLEASE HELP!!

Thanks!

Initial Value For Combobox
I can't get a combobox show a specific value on form load in "dropdown list" mode. It's OK in "dropdown combo" mode, I just use cboxxx.Text = "bla-bla" . In "dropdown list" mode it comes up with compile error, saying text property is read-only.

Set Initial State Of CheckBox?
Is it possible to set a CheckBox in Excel to be unchecked every time the workbook is opened?

My CheckBox reveals instructions for a user to follow - so I obviously want the text hidden each time they open the workbook.

Any ideas?

GH

Combo Box Initial Caption?
i've seen several how-do-i-make-selecting-options-in-my-combo-box-do-stuff threads, and a few how-do-i-add-options-to-my-combo-box threads, but haven't seen this one, am i a moron?

I want a dropdown listbox to have an initial caption, but the text property is read only and, although it doesn't show in runtime n e way, is auto set to the name of the combo box. before anything is selected in runtime, it is blank, haw can i give it a caption?

Initial Form Doesn't Appear
I'm certain that I'm doing something really stupid in VB6. I have a miniature application that I want to display a form for a short period and then go away. When I started building the application the form showed up just fine. Now it doesn't show up at all. I have set the Visible Property to True and I have included a Form1.Show and Form1.Visible to little effect. WHen I included them, the border would show up but nothing inside appeared and it appeared to be transparent. Help, this is incredibly frustrating.

TIA
-joe-


Code:
Option Explicit
-------------(General)---( Declarations)------------
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
---------------------------------------------------
Private Sub Form_Load()
Dim Quote(500)
Dim Source(500)
Dim cnt
Dim RandomQuote
cnt = 0
Open "Quotes.txt" For Input As #1
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, Quote(cnt) ' Read Quote & Source into arrays
Line Input #1, Source(cnt)
cnt = cnt + 1
Loop
Randomize
RandomQuote = Int(cnt * Rnd)
Close #1 ' Close Input file
Open "signature.html" For Output As #2
Print #2, "<font color=red><b>";
Print #2, Quote(RandomQuote);
Print #2, "</font><br>"
Print #2, "<font color=blue><i>";
Print #2, Source(RandomQuote);
Print #2, "</i></font></b>"
Close #2
Wait (6)
End
End Sub

-------------(General)---(Wait)--------------------------

Public Sub Wait(Seconds As Single)

Dim lMilliSeconds As Long
lMilliSeconds = Seconds * 1000
Sleep lMilliSeconds

End Sub

Initial Start Of Program
I am trying to write a VB prog and I would like for the user after installation, see the 'about box', then into a personal info box after closing about, then into a vehicle info box after closing the personal info. Once they have closed the above mentioned boxes, they will be looking at the main page of my program. I want these 3 boxes to show only once [at initial startup] but will be accessable anytime there after thru the menubar which I already have linked there.

Code I am using is:

Private Sub cmdOK_Click()
Unload Me
frmrv.Show
frmperson.Show
End Sub

It is apparently wrong, because it causes some code on the main prog not work work now.

Thank You

Browse Initial Folder
Any one noiticed that browsing initial folder code from some web site only works if user has selected the initial foder by themselves the first time?
and then it works because it was remembering what user selected the first time.

Initial Status When I Click On XXX.VBP
When I click on xxx.vbp, I see the Project window with a list of my forms and modules.

One of them is shaded, meaning it is the current active thing I am working on.

My problem is that the wrong one is shaded. I always have to click on the other one that I want.

How can I save my project so the item I am working on last is the active item the next time I open the project.

If this cannot be generally done, is there any way I can chose a project to be active by modifying one of the many VB component files?

Mr. Mac

Text Box - Highlight Initial Value
I have data entered in a text box as a default value when the form loads, how do I have that text highlighted in blue (selected) when the form loads? I looked in the properties of the textbox but didn't see anything.

Hope this is an easy one, thanks!

CommonDialog Initial Path
Is there a way to force my common dialog to start in a certain directory?

My users will change it to another directory, but then not pay attention next time and it saves something in an unexpected spot (the last folder they used).

I could solve this by setting the path before opening the Save dialog, but am unsure how.

Any help is appreciated!

Thanks,

Seting Configuration Initial From VB
Hi

How do I configure my VB to be like the first instalation ?

Why each time that open my project the windows are hash in the form, How do I for let It Write ?

Printing Last Name With First And Middle Initial
I'm currently working a program that will allow the user to enter their last name, and first and middle initial. Here's my code:

begin
write('enter your last name: ');
readln(LastName);
write('enter your first initial: ');
readln(initialf);
write('enter your middle initial: );
readln(initialm);
writeln(LastName, ', initialf, ', initialm)
end.

When I run it for the name R.M. Jones, I get the following: Jones(for the last name), initialf(for the first initial), and M(for the middle initial). Can someone tell me what's wrong?

Initial File Directory With VB6
How can I set the initial direcotry for a file save dialog box to the users My Documents directory? For example C:Documents and SettingsSome UserMy Documents.

Set Window Initial Position
HI,

i have a mdi application and each childform has some textbox, when a make double click into it should be appear a dialog to select diferents items, but i cant achive that the dialog appears in the right botton corner of the text box.

please help meeee!!!


Thanx.

Initial Catalog Value Is Not Changing
Hi, In class module I have created public property procedures Data source name, userid , password and databse name. In a sample form I am assigning for value for that. Initial Catalog = Databasename. First time it is executed, Second time I changed the value for datasourcename and database name. While running the project, datasource name value is changed but initial catalog values remain same.
Can any please tell me the reason.

Accessing Variables Or Control Values Of A Form From Another Form - ACCESS
I use MS Access for both front-end and back end. How do I retrieve controls belonging to one form in another in Access. Also, how do I retrieve values of public/global variables that I assign value to in one form from another form. I have referred the net and everywhere I see examples only for VB which does not seem to do the magic in Access. Can anyone please help?

Setting The Initial State Of A Checkbox
Every time a user opens my workbook I want the CheckBox to be unchecked.

I can do this using a CheckBox from the Control Toolbox. I use this code:

Sheet1.CheckBox1.Value = 0

However, I'm having to use a CheckBox from Forms to ensure compatability with Excel 95 (ie not using Active X)

If I use this code to set the initial state of the checkbox to being unchecked then I get a "424 Object expected" runtime error:

CheckBox60.Value = 0

Does anyone know what the correct syntax would be?

Hope someone does - My Windows 95 client is expecting this by Saturday.

GH

Preselecting Initial Row In ListBox With ControlSource
I have a UserForm with a ListBox set up to display a worksheet range as follows:


Code:
Private Sub UserForm_Initialize()
.
.
.
Me.Tag = "Initialization"
.
.
.
Set isws = isc.SourceWS
With isws
FirstRow = isc.SourceHdrRows + 1
LastRow = .Cells((65536), 1).End(xlUp).Row
Set ListRng = .Cells(FirstRow, 1).Resize(LastRow - FirstRow + 1, isc.SourceCols)
Set isc.SourceListRng = ListRng
sListRngAddr = ListRng.Address(External:=True)
End With
Set IndexRng = wvws.Range("ItemIndex")
If IsNumeric(wvws.Range("ItemIndex").Value) Then
ItemIndex = wvws.Range("ItemIndex").Value
Else
ItemIndex = -1
wvws.Range("ItemIndex").Value = -1
End If
With ListBox1
.RowSource = sListRngAddr ' triggers Change, not active
.BoundColumn = 0 ' triggers Change, not active
Me.Tag = "" ' activates Change
' Save the ListIndex in the WorkValues Sheet as ItemIndex
' must be set after BoundColumn, but first to allow Change event
sCtlSrcAddr = wvws.Range("ItemIndex").Address(External:=True)
.ControlSource = sCtlSrcAddr ' triggers Change, NOW active
.TextColumn = TextCol ' does not trigger Change
.ColumnHeads = True
.ColumnWidths = SetColumnWidths(isc.SourceISC.Widths)
'.MatchEntry = fmMatchEntryComplete
'.MatchEntry = fmMatchEntryFirstLetter
.MatchEntry = fmMatchEntryNone
End With
.
.
.
What I am expecting is for the ListBox to be displayed with the row indicated by ItemIndex "preselected" as a default choice (just hit enter and that row is used).

BTW, ItemIndex is actually the saved index of the last row selected from the previous time this range was shown in the ListBox.

However, the ListBox is always displayed with the first row outlined with a "row-cursor marquee" (i.e., the current row for movement with the cursor keys, but NOT selected). Running in debug mode confirms that ListIndex has been set to the desired ItemIndex value.

Why isn't the row selected?

Other than this initial state, the ListBox works as expected, using either cursor keys or mouse clicks to select various rows.

The ListBox has a Change Event macro that modifies a number of TextBox controls with values from the selected [source range] row. If the Add button is clicked, values from the selected [source range] row (and/or modified values from the corresponding TextBox controls) or used to update a target worksheet. In short, this dialog is used to select a row of values from a source worksheet to update a target worksheet.

Also, there is another annoying glitch in this process. The dialog has a button, which when clicked displays another dialog to select a different source range (actually a different source worksheet) for the ListBox on the initial dialog. This has the following event procedures:


Code:
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = True
CommandButton2_Click
End Sub
Private Sub CommandButton2_Click()
' Use Job Type/Phase button clicked
.
.
.
' save Phase index name so it can be easily picked up for next
' display of item selection list
PhaseIndex = JobType & "." & PhaseName
.Range("PhaseIndex").Value = PhaseIndex
End With
Unload Me
End Sub
The problem here is that if I double-click to select a "Phase Index" (rather than click to select row and then click on "Use ..." button), I cannot suppress the click from being detected by the calling "Item Selection" UserForm, which usually winds up selecting an irrelevant row in the ListBox on the "Item Selection" UserForm. Of course, if I avoid the double-click (or if the location of the double-click does not correspond to a row in the "Item Selection" ListBox), it reverts to my first problem, NO row is selected.

Any ideas?

The UserForm.Tag property is used to flag whether the initialization of the listbox has completed enough for the ListBox_Change event procedure to initialize other TextBox controls on the form from the currently selected row. Ironically, when the ListBox_Change event procedure is allowed to run (after Me.Tag is cleared), it gets the correct value of ListBox.ListIndex to initialize the TextBox controls from the source row that I wanted to be selected in the ListBox, even though the row is not shown as selected.

Copyright © 2005-08 www.BigResource.com, All rights reserved