0
我在here中看到完全相同的問題,但我想知道vb(窗體)中的代碼。 我有自己的變量存儲在如何將存儲的數據恢復到vb.net中的確切標籤?
昏暗的姓氏,姓,中間名,年齡作爲字符串
和數據都保存在記事本中。我怎麼能把他們放回他們的確切標籤。 我拉布勒之一是
lbl_surname.Text
感謝。
我在here中看到完全相同的問題,但我想知道vb(窗體)中的代碼。 我有自己的變量存儲在如何將存儲的數據恢復到vb.net中的確切標籤?
昏暗的姓氏,姓,中間名,年齡作爲字符串
和數據都保存在記事本中。我怎麼能把他們放回他們的確切標籤。 我拉布勒之一是
lbl_surname.Text
感謝。
我發現這下面的代碼幫我,
昏暗的TextLine作爲字符串
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
希望它會幫助的人誰需要它!