• Log in or sign up for an account here: https://www.sythe.org/login

multi text box saves????

  • Thread starter Thread starter meeman666
  • Start date Start date
M

meeman666

Guest
multi text box saves????
ok,
i'm making a program that has a save feature and i know the code to save the file with one text box is

Code:
Private Sub Command2_Click()
CommonDialog1.Filter = "All Files [*.*]|*.*"
CommonDialog1.ShowSave
FSave = CommonDialog1.FileName
Open FSave For Binary Shared As #1: Close #1: Kill FSave
Open FSave For Output Shared As #1
Print #1, Text1.Text
Close #1
End Sub

and to load that would be

Code:
Private Sub Command1_Click()
CommonDialog1.Filter = "All Files [*.*]|*.*|data Files [*.dat]|*.dat|"    
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
FOpen = CommonDialog1.FileName
Open FOpen For Input As #1
Text1.Text = Input(LOF(1), 1)
End Sub

but whats the code to save and load if what needs to be saved and then loaded has more then one text box. I've tested many different ways but none have worked.

Please help.
Thanx.
 
multi text box saves????
Well i do not know about opening as i do not wanna go test codes but i know that for saving try this..

Code:
Private Sub Command2_Click()

CommonDialog1.Filter = "All Files [*.*]|*.*"
CommonDialog1.ShowSave
FSave = CommonDialog1.FileName
Open FSave For Binary Shared As #1: Close #1: Kill FSave
Open FSave For Output Shared As #1
Print #1, Text1.Text, Text2.Text
Close #1

End Sub

What i did was that i added Text2.Text after Text1.Text here

Code:
Print #1, Text1.Text, Text2.Text

Tell me if it works.

EDIT: To test how this works save the file in text file and look at the file in notepad afterwards.
 
multi text box saves????
that seems to work but how do i load that. That should save the both but how would i load them?
 
multi text box saves????
Please note: I am not replying to this because I feel like being an idiot. I have been asked multiple times to make a load function for the above as well.

Now everyone can stop spamming my PM box and have the bloody function.

Enjoy and leave me alone.

Code:
Option Explicit

Private Sub CmdSave_Click()
      On Error GoTo err:
      Dim ctl As Control
      Dim sFile As String
      CommonDialog1.Filter = "Text Files [*.txt]|*.txt"
      CommonDialog1.ShowSave
      sFile = CommonDialog1.FileName
      Open sFile For Output As #1
      For Each ctl In Me.Controls
            If TypeOf ctl Is TextBox Then
                  Print #1, ctl.Text
            End If
      Next ctl
      Close #1
err:
      If err.Number = 75 Then
            'Cancel was pressed
      End If
End Sub

Private Sub CmdLoad_Click()
      On Error GoTo err:
      Dim ctl As Control
      Dim sFile As String
      Dim Str2 As String
      Dim i As Integer
      CommonDialog1.Filter = "Text Files [*.txt]|*.txt"
      CommonDialog1.ShowOpen
      sFile = CommonDialog1.FileName
      Open sFile For Input As #1
            Str2 = Input(LOF(1), #1)
      Close #1
      i = 0
      For Each ctl In Me.Controls
            If TypeOf ctl Is TextBox Then
                  ctl.Text = Split(Str2, vbCrLf)(i)
                  i = i + 1
            End If
      Next ctl
err:
      If err.Number = 75 Then
            'Cancel was pressed
      End If
End Sub
 
Runescape Gamblingrunescape gambling
Back
Top