如何在vb.net中将存储的数据放回精确的标签中?

如何在vb.net中将存储的数据放回精确的标签中?,vb.net,Vb.net,我在中看到了完全相同的问题,但我想知道vb(窗口形式)中的代码。 我已将变量存储在 Dim姓氏、姓氏、中间名、年龄作为字符串 数据保存在记事本中。我怎样才能把它们放回原来的标签上呢。 我的一个标签是 lbl_姓氏.Text 谢谢。我发现下面的代码帮助了我 将文本行变暗为字符串 Dim objReader作为新的System.IO.StreamReader(openfile) Dim aryTextFile()作为字符串“这将设置一个数组来存储行的各个部分 “圆括号是空的,因为我们不知道每行需要多

我在中看到了完全相同的问题,但我想知道vb(窗口形式)中的代码。 我已将变量存储在

Dim姓氏、姓氏、中间名、年龄作为字符串

数据保存在记事本中。我怎样才能把它们放回原来的标签上呢。 我的一个标签是

lbl_姓氏.Text


谢谢。

我发现下面的代码帮助了我

将文本行变暗为字符串

Dim objReader作为新的System.IO.StreamReader(openfile)
Dim aryTextFile()作为字符串“这将设置一个数组来存储行的各个部分
“圆括号是空的,因为我们不知道每行需要多少(单独的项目)
如果System.IO.File.Exists(openfile)=True,则“查看文件是否存在”
当objReader.Peek()-1'查看文件结尾时,若并没有更多行,RTE将返回-1
TextLine=objReader.ReadLine()'读取行
lbl_data.Text=lbl_data.Text&vbNewLine&TextLine
'提取所需数据
aryTextFile=TextLine。圆括号内的拆分(“,”)符号用于分隔行中的每个元素,在本例中为逗号。
'对于i=0到UBound(aryTextFile)'UBound表示数组的上边界,即变量的最大数量
'MsgBox(aryTextFile(i))
“接下来我
'将行中所需的位放在表单的适当位置
需要姓氏=aryTextFile(0)的第一部分
年龄=aryTextFile(3)需要第二部分
Middlename=aryTextFile(1)
Lastname=aryTextFile(2)
mobile=aryTextFile(4)
lbl_姓氏.Text=姓氏'将数据存储到标签中以供显示
lbl_lastname.Text=lastname
lbl_middlename.Text=middlename
lbl_age.Text=age'将数据存储到标签中以供显示
lbl_mob.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