ここでもまったく同じ質問が表示されますが、vb(ウィンドウ形式)のコードを知りたいです。変数をに保存しました
Dim Lastname、Surname、Middlename、age As String
データはメモ帳に保存されます。どうすればそれらを正確なラベルに戻すことができますか。私のラベルの1つは
lbl_surname.Text
ありがとう。
以下のコードが役に立ったことがわかりました。
文字列としての薄暗いテキスト行
Dim objReader As New System.IO.StreamReader(openfile)
Dim aryTextFile() As String 'this sets up an array to store the seperate parts of the line
' round brackets are blank because we don’t know how many we need (separate items) there are on each line
If System.IO.File.Exists(openfile) = True Then 'see if file exists
While objReader.Peek() <> -1 'takes a peek to find end of file, rteturns -1 if no more lines
TextLine = objReader.ReadLine() 'Read line
lbl_data.Text = lbl_data.Text & vbNewLine & TextLine
'Extracting required data fr
aryTextFile = TextLine.Split(",") 'Inside the round brackets is symbol is used to separate each element in the line, in this case a comma.
' For i = 0 To UBound(aryTextFile) 'UBound means upper boundary of array, ie max number of variables
'MsgBox(aryTextFile(i))
' Next i
' Put required bits from line in appropriate places on form
Surname = aryTextFile(0) 'first part needed
age = aryTextFile(3) 'second part needed
Middlename = aryTextFile(1)
Lastname = aryTextFile(2)
mobile = aryTextFile(4)
lbl_surname.Text = Surname 'Storing data into label for display
lbl_lastname.Text = Lastname
lbl_middlename.Text = Middlename
lbl_age.Text = age 'Storing data into label for display
lbl_mob.Text = mobile
End While
End If
End Sub
必要な方のお役に立てれば幸いです!