?
Solved

Saving a file....

Posted on 1998-12-20
5
Medium Priority
?
170 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
  • 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 400 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

571 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