0

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

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by waynespangler
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.