Hi,

I'm new to VB.net. I'm stuck in a problem. Hope some one helps me out. Thanks in advance.

The issue is... I have created a file say xyz.txt in C drive. The contents of the file is like this...

COMMAND(START) TIME(TODAY)
COMMAND(CLICK) TIME(TOMORROW)

My issue is, I want to read this text file and display the following in a label

START TODAY
CLICK TOMORROW

Any idea, code - how to do this?
Your help is very much appreciated.

Regards,
Vinay

Try this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim str As String = My.Computer.FileSystem.ReadAllText("C:\test\myFile.txt")
        Dim ary As String() = Split(str, vbNewLine)
        For x As Integer = 0 To UBound(ary)
            Dim startPos As Integer = ary(x).IndexOf("(") + 1
            Dim endPos As Integer = ary(x).IndexOf(")")
            TextBox1.Text &= ary(x).Substring(startPos, endPos - startPos) & " "
            startPos = ary(x).IndexOf("(", endPos) + 1
            endPos = ary(x).IndexOf(")", startPos)
            TextBox1.Text &= ary(x).Substring(startPos, endPos - startPos) & vbNewLine
        Next
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.