Results 1 to 8 of 8

Thread: Variables help

  1. #1
    Guest

    Talking

    I want to store some variables within the EXE file itself so that when the program is closed and re-run, the variables will still be remembered.

    The variables are from a textbox which asks the user for his name. I want to be able to store it so that it can greet him on his next use.

    how do i go abt doing this?

    thx

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    '
    'another opiton is to use SaveSetting and GetSetting
    
    Option Explicit
    '
    ' Variant to hold 2-dimensional array returned by GetSetting.
    Dim MySettings As Variant
    
    'to test this out
    'make a std project
    'add a textbox with "" value for text
    'add command1 and command2
    'run the app
    'click command1
    'click the x to unload the project
    'reload the project and text1 will now have the text that
    'was in it when you quit
    
    'if you want to delete the save settings click on command2
    
    Private Sub Command2_Click()
    'this will delete it from the register if you are finished
    'with playing with it
    
    DeleteSetting "project1", "TextboxValue"
    
    End Sub
    
    Private Sub Form_Load()
    'this will load it into the register
       Text1.Text = GetSetting("project1", "TextboxValue", "Value", 0)
    End Sub
    
    
    Private Sub Form_Unload(Cancel As Integer)
    'this will save it into the register when you quit
        SaveSetting "project1", "TextboxValue", "Value", Text1.Text
    End Sub
    
    
    Private Sub Command1_Click()
    'load the text1.text with whatever
        Text1.Text = "Shame on you, you went and did it!"
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    thanks, but what do you recommend if i dont want to play around with the registry?

  4. #4
    Guest
    I dont want to use the registry because the app will be like a greeting card. You enter a name and then send it off to the receipient.

  5. #5
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    You could try writing the variables in question to an external file, and read them into the program when needed.

  6. #6
    Guest
    I tried it but i want to keep the no. of files distributed to the minimum. You know like those messagemates, you can configure it and then it saves into the file itself

  7. #7
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183

    Smile

    I think you should use the WritePrivateProfileString and SetPrivateProfileString API calls. With these call you can create an INI file and store info in there.

  8. #8
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    Whether it is an *.ini file or just a normal text file, it looks as if you are going to have to write to as file. A typical text file might be 256 bytes or less. It hardly counts as a file compared to the size of the distributed *.exe.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width