Solved

Saving a file....

Posted on 1998-12-20
5
160 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

Industry Leaders: 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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

636 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