Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

storing values in data-input windows

Status
Not open for further replies.

steves2002

Programmer
Jun 17, 2002
3
CA
I'm new to VB and this question may a simple one. I'm setting up a set of VB windows which require the user to input numeric values for different variables. Once all fields are input, the user closes the window. However, if that specific input window is re-opened, the input fields are blank. How can I ensure that, upon a second opening of that window, the previous values are shown in the input fields?

Thanks

Steve
 
Steve,
As long as the app is not ended, you could set the values of the input fields to a variable defined in a module as

Public [variablename] as [variable type]

Be sure to use the right conversion function (ie Cint to convert to integer).

variablename = Cint( datafield.Text )


if the app is terminated. you will need to write the data out to a file or the registry.

easiest is to look at the functions
GetSetting and SaveSetting
in the MSDN library.

I hope this was helpful,
Uprightman
 
upright - thanks for the response. I tried to use the public command, but it gave an error when I ran it. Here's my section of code:

Private Sub Command1_Click()
Dim B As Single, H1 As Single, H2 As Single
Dim Ax As Single, Ay As Single, Az As Single
Dim dstar As Single

B = Val(TextB.Text)
H1 = Val(TextH1.Text)
H2 = Val(TextH2.Text)
Ax = Val(TextAx.Text)
Ay = Val(TextAy.Text)
Az = Val(TextAz.Text)
dstar = Val(TextDstar.Text)

End Sub
 
Uprightman - I figured out how to use 'Public' in a module and have applied it to my code. However, the variable boxes are still blank when I re-open the window. Any ideas?

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top