473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do I recall a value added when I re-open my EXE?

AsSeenonTV
Hey there! I will admit I am new to these Message Boards and to Visual Basic 6, but I am an experienced programmer when it comes to Visual Basic for Excel.

Now with working with Excel, I am able to save an input (to a cell) and recall it back to the userform when I re-open that Excel project. Now I'm working on a new project that I can take anywhere (without having Microsoft Office loaded on the computer).

Here's what I am trying to accomplish:

I am trying to make an Inventory List for an online game that I play. When I receive new items, I want to add it to the form (manually, via a text box) and update the program to include the new value. When I close and reopen my EXE for my inventory and select the item, I want the updated value to appear in a Label.

Here's the Code for the current project I have: The first Combo Box contains the type of items and the second Combo Box contains the actual Item names. In helping me, you can preserve the list names I have provided for the code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Combo1.Clear
  3. Combo2.Clear
  4.  
  5. Combo1.AddItem ("Item 1")
  6. Combo1.AddItem ("item 2")
  7. Combo1.AddItem ("Item Three")
  8. Combo1.AddItem ("iTeM IV")
  9.  
  10. End Sub
  11.  
  12. Private Sub Combo1_Click()
  13. If Combo1.Text = "Item 1" Then
  14. Combo2.Clear
  15. Combo2.AddItem ("Sub-Item 1")
  16. Combo2.AddItem ("sub-item 2")
  17. Combo2.AddItem ("sub-item 3")
  18. Else
  19. If Combo1.Text = "item 2" Then
  20. Combo2.Clear
  21. Combo2.AddItem ("Sub-Item 4")
  22. Combo2.AddItem ("sub-item 5")
  23. Combo2.AddItem ("sub-item 6")
  24. Combo2.AddItem ("Sub-Item 7")
  25. Combo2.AddItem ("sub-item 8")
  26. Combo2.AddItem ("sub-item 9")
  27. End If
  28. End If
  29. End Sub
  30. Private Sub combo2_click()
  31. If Combo2.Text = "Sub-Item 1" Then
  32. Text1.Text = 23
  33. Else
  34. Text1.Text = ""
  35. End If
  36. End Sub
  37.  
Thank you all for your assistance!
Apr 22 '07 #1
3 2365
Killer42
8,435 Expert 8TB
I'd say there are two main options for saving and restoring your data.
  1. Write the info out to a file (just a simple text file will do) before exiting (or each time the info changes). Read the file in when your program starts.
  2. Store it to the registry. This is relatively simple in VB6 and later.
Hm... on second thought, the latter would be useless if you want to carry the data with you, as well as the program. Probably best to stick with the former.

The simpler way to deal with a text file is by using the built-in keywords Open, Close, Print #, Input # and so on. The FileSystemObject object provides considerably more functionality, but is (only slightly) more complex to work with and requires you to add a reference (Microsoft Scripting Runtime) to your project.
Apr 23 '07 #2
Well, If that is the case, then I shall do all my inventory updating from my home computer, or load a copy of Office onto my work computer. That seems a bit too expert for me to use at my current knowledge level of Visual Basic 6. I will play around with VB6 until I feel comfortable coming back to this subject and trying my luck again at accomplishing what I am trying to do.

Thank you anyways for your assistance, Killer42!!
Apr 23 '07 #3
Killer42
8,435 Expert 8TB
Well, If that is the case, then I shall do all my inventory updating from my home computer, or load a copy of Office onto my work computer. That seems a bit too expert for me to use at my current knowledge level of Visual Basic 6. I will play around with VB6 until I feel comfortable coming back to this subject and trying my luck again at accomplishing what I am trying to do.

Thank you anyways for your assistance, Killer42!!
Fair enough.

I should point out, though, that using a text file via the Open/Close and so on is very simple. For example, let's say you just want to store the string variable strMyString into text file "MyFile.txt". You can do it in three lines...
Expand|Select|Wrap|Line Numbers
  1. OPEN "MyFile.txt" For Output Access Read Write Lock Write As #1
  2. Print #1, strMyString
  3. Close #1
And to read it back later...
Expand|Select|Wrap|Line Numbers
  1. OPEN "MyFile.txt" For Input Access Read Shared As #1
  2. Line Input #1, strMyString
  3. Close #1
Actually, I tend to be a bit long-winded with my options on the open. A lot of people leave most of them as default. So you could probably code something even simpler, such as (untested)...
Expand|Select|Wrap|Line Numbers
  1. OPEN "MyFile.txt" As #1
  2. Print #1, strMyString
  3. Close #1
If you check the doco, it'll tell you which parts are optional.
Apr 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
5
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the...
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.