Solved

Saving a file....

Posted on 1998-12-20
5
155 Views
Last Modified: 2010-05-03
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.
0
Comment
Question by:plastic_74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 4

Expert Comment

by:idcanada
ID: 1451691

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



0
 
LVL 3

Expert Comment

by:Sendoh
ID: 1451692
Hi !
Beside registry, you can save it to fiel as well.
Hope it'll help you.
0
 
LVL 2

Author Comment

by:plastic_74
ID: 1451693
Hei...guys what I need is code. How do I write the code... Open files, Save files, Is what I need. Not REGISTRY !
0
 
LVL 3

Accepted Solution

by:
Sendoh earned 200 total points
ID: 1451694
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
 
LVL 3

Expert Comment

by:Sendoh
ID: 1451695
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question