vb6 Saving Strings and Integers

Discussion in 'Software' started by mastermosley, Oct 18, 2005.

  1. mastermosley

    mastermosley Sergeant

    I have a big problem. I have made a program that stores your Hosting information like Database, FTP login and stuff and I have a loggin at the beggining. I am really new to VB6 so i dont no if i am doing this right anyway.

    First I made a module and declared my strings:

    dim strUsername as string
    dim strPassword as string

    I want to be able to save the strings becuase I have a settings area in the program that allows you to change your username and password and stuff. How do I save the strings so next time I log on and when I switch forms the password will be stored in the string and I will have to use the password that I changed it to.

    I also have a bunch of other strings that hold the ftp and database information also.

    Can you give me some code and explain it please?

    Thanks in advance,
     
  2. Kodo

    Kodo SNATCHSQUATCH

    use a public property in a module

    google VB6 public properties
     
  3. mastermosley

    mastermosley Sergeant

    So if i use these global strings and stuff they will save automatically or do i use code for that?
     
  4. Kodo

    Kodo SNATCHSQUATCH

    please define what you mean by save..
    in memory as in a session or to a file?
     
  5. mastermosley

    mastermosley Sergeant

    Ok I figured out how to set public integers so everything saves so that i can move around the program and the integers have the same stuff and i can call them anywhere.

    Now i want to save the strings to a file so that the information stored in the strings will be there after I close the program and re-start it. Can you help me out with this please?
     
  6. Kodo

    Kodo SNATCHSQUATCH

    splash screens are good for this.. you load up a splash screen (it's just another form) and in that form you load the data from the file and populate properties in an module like you did just before.

    Saving and reading from the file can be done using the FileSystemObject

    You seem pretty capable of taking the info I throw at you and applying to so give it a shot and if you have problems , let me know.
     
  7. mastermosley

    mastermosley Sergeant

    I am still having problems. I am not sure what you mean. Here is my code located in the module.

    Public strpass As String, strUser As String
    Public strFtpAdd As String, strFtpUser As String, strFtpPass As String
    Public strDatHost As String, strDatUser As String, strDatPass As String, strDatName
    Public strPopAdd As String, strPopUser As String, strPopPass As String
    Public strUrlAdd As String

    That is all in the right format and stuff because it works.

    All I want to do now is to safe all of the information located in the strings to a file, preferably a file that someone cant open and view the info. So when i run the program again all of the info located in the strings are the exact same as when I closed the program.

    Once again please help me, if you have the time in detail please.
     
  8. Kodo

    Kodo SNATCHSQUATCH

    FSO
    http://builder.com.com/5100-6373-1050078.html

    read this. It will help you with understanding how to create files, read files etc.

    the other part requires encryption.. work on saving the files with the content first, THEN work with encryption.
     
  9. mastermosley

    mastermosley Sergeant

    I understand how to do it that way but that means I am using a text file. Does the formula work the same way if I want to use a .dat file? Also the:

    Dim fso As New FileSystemObject doesnt work. Says user defined type not defined.
     
  10. Kodo

    Kodo SNATCHSQUATCH

    yes, this will write any FILE (.dat means nothing really, it's still a file, in other words, a file is a file is a file is a file no matter what the extension is it's still a file.. ;) :) )

    try
    dim fs as new ("scripting.filesystemobject")
     
  11. mastermosley

    mastermosley Sergeant

    Still doesn't work
     
  12. Wookie

    Wookie Sergeant Major

    Paste your code.
     
  13. Kodo

    Kodo SNATCHSQUATCH

    I hate VB6..
    any way.. put this into a button click event.. and watch in all the glory

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile("c:\testfile.txt", True)
    a.WriteLine ("This is a test.")
    a.Close
     
  14. x411man

    x411man Private E-2

    I would use a comon diologe tool for this. Here is an example of some code from a program that I wrot when I was just learning VB6. The whole project was used to save info about Baseball cards. There are many other ways of doing this, using VisData or or an adoc control. I have code examples of both that I could post if needed.

    Private Sub mnuSave_Click()
    Dim i As Integer
    cdlOpenSave.Filter = "BBCard Data|*.dat"
    cdlOpenSave.ShowSave
    FileName = cdlOpenSave.FileName
    If Len(FileName) <> 0 Then
    Open FileName For Random As #1 Len = Len(BBCardArray(1))
    For i = 1 To ArrayCounter
    Put #1, , BBCardArray(i)
    Next i
    Close #1
    MsgBox ArrayCounter & " Baseball Cards were saved."
    Else
    MsgBox "no file was opened.", vbCritical, "Error"
    End If

    End Sub
     
  15. x411man

    x411man Private E-2

    In my last post I said you could use and "adoc" control, I ment to say adodb control...sorry....
     
  16. mastermosley

    mastermosley Sergeant

    Thanks fur all ur help, I just installed them in the regisry because there were only a few.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds