Saving a file....

Can someone give me an answer on how to save my programs inputs. I'm using about 10 Textbox as input to some of my calculation....for example in Textbox1(in runtime mode) I keyin '1' then I have this Menu on top of my screen, where I put &Save....

So is there away to save that input ? "1" And how can I load it back the "1" when next time I run it.
LVL 2
plastic_74Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

idcanadaCommented:

Use the registry,
GetSetting and SaveSetting are the elements.
Look in the VB Help for how to use these witha full explanation.



0
SendohCommented:
Hi !
Beside registry, you can save it to fiel as well.
Hope it'll help you.
0
plastic_74Author Commented:
Hei...guys what I need is code. How do I write the code... Open files, Save files, Is what I need. Not REGISTRY !
0
SendohCommented:
Hi !

The code as follow :

 Dim strSave as string
 Dim FileNum As Integer

 For i=0 to 10
      if i <> 0 then
           strSave = strSave & "," & textArray(i).text
      else
           strSave = textArray(i).text
      end if
 next i
   
 FileNum = FreeFile
 Open "save.txt" For Output As FileNum
 Print #FileNum, strSave
 Close FileNum

Every text field are seperated by ",".
When you need to get back the data just :

On Error GoTo errorhandler:
    Dim FileNum As Integer
    Dim retval As String
   
    FileNum = FreeFile
    Open save.txt For Input As FileNum
    Input #FileNum, retval
    Close FileNum
    'code to extract the retval fiel based on ','
   
errorhandler:
    'file not found error so assign default print schedule
    If Err.Number = 53 Then
          msgbox "File Not found"
    End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SendohCommented:
Hi !
Extra code for extract !!

Function ExtractString(ByVal strSource As String, ByVal intPosition As Integer, ByVal strDelimiter As String) As Variant
    Dim intPos As Integer
    Dim intLastPos As Integer
    Dim intLoop As Integer
    Dim intPos1 As Integer

    intPos = 0
    intLastPos = 0
    intLoop = intPosition
    Do While intLoop > 0
        intLastPos = intPos
        intPos1 = InStr(intPos + 1, strSource, strDelimiter)
        If intPos1 > 0 Then
            intPos = intPos1
            intLoop = intLoop - 1
        Else
            intPos = Len(strSource) + 1
            Exit Do
        End If
    Loop
    ' If we didn't find a comma and we're still on the first piece of the
    ' string, we have an error.  We must have at least one delimiter in our strings!
    If intPos1 = 0 And (intLoop = intPiece Or intLoop > 1) Then
        ExtractString = Null
    Else
        ExtractString = Mid(strSource, intLastPos + 1, intPos - intLastPos - 1)
    End If
End Function

Private Sub Command1_Click()
    Dim s As String
   
    s = ExtractString("a,b,c,d", 2, ",")
    'should be "b"
    MsgBox s
End Sub

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.