Hejsa!
jeg sider og leger med et program hvor jeg har lavet 8 text boxe med en enkelt linie i værd og en multiline text box.
Men jeg kan ikke finde ud af hvordan jeg skal loade multiline boxen.
Når jeg loader henter den kun den sidste linie i multiline boxen
Jeg er helt ny inden for vb. Please help
Her er min kode.
Private Sub Command1_Click()
Dim location As String
Dim nFile As Integer
Dim sTemp As String
Dim nEqualsSignPos As Integer
nFile = FreeFile()
On Error GoTo error_handel_1
' Loads open box
CommonDialog1.ShowOpen
location = CommonDialog1.FileName
Open location For Input As nFile
' input files into text
Do Until EOF(nFile)
Input #nFile, sTemp
If Len(sTemp) > 0 Then
nEqualsSignPos = InStr(sTemp, "=")
nEqualsSignPos = nEqualsSignPos + 1
If InStr(sTemp, "navn") Then
Text1.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "tlf") Then
Text2.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "mærke") Then
Text3.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "model") Then
Text4.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "motor") Then
Text5.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "stel") Then
Text6.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "km") Then
Text7.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "år") Then
Text8.Text = Mid(sTemp, nEqualsSignPos)
ElseIf InStr(sTemp, "") Then
Text9.Text = Mid(sTemp, nEqualsSignPos)
End If
End If
Loop ' go around again...
Close nFile
error_handel_1:
End Sub
Private Sub Command2_click()
Dim filelocation As String
Dim FF As Long
FF = FreeFile()
On Error GoTo error_handel_2
' loads save as box
CommonDialog1.ShowSave
filelocation = CommonDialog1.FileName
Open filelocation For Output As #FF
Print #FF, "navn=" & Text1.Text
Print #FF, ","
Print #FF, "tlf=" & Text2.Text
Print #FF, ","
Print #FF, "mærke=" & Text3.Text
Print #FF, ","
Print #FF, "model=" & Text4.Text
Print #FF, ","
Print #FF, "motor=" & Text5.Text
Print #FF, ","
Print #FF, "stel=" & Text6.Text
Print #FF, ","
Print #FF, "km=" & Text7.Text
Print #FF, ","
Print #FF, "år=" & Text8.Text
Print #FF, ","
Print #FF, "=" & Text9.Text
Close #FF
error_handel_2:
End Sub
Håber nogen kan hjælpe!
Indlæg senest redigeret d. 30.05.2009 22:25 af Bruger #15002