954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Visual basic : Read a command from a text file

Greetings
I am on a project where the application read a text and execute commands in the text... i am having problems in the part of finding the command from the text.
So let's say i have a file with the following text :

message:Hello this is a message ! metext:New title

So when the software find a line starting with "message:" will pop up a message saying the part after the " : " on the line witch is "Hello this is a message"
If he finds a line starting with "metext:" will change the software title to "New title", (Me.text = "New title" )P.S. : The text will be containing only one line ( only one command ) this was just an example of cases.

I hope you hot what i mean.
Please could you help me with the code ?

Thanks a lot

a1a4a
Newbie Poster
18 posts since Dec 2010
Reputation Points: 10
Solved Threads: 1
 

I got the code :

Dim lines() As String = IO.File.ReadAllLines("C:\Users\A1A4A\Desktop\text.txt")
        For Each line As String In lines
            Dim command() As String = line.Split(":")
            If (command(0) = "metext") Then
                Me.Text = command(1).Trim()
            ElseIf (command(0) = "msgbox") Then
                MsgBox(command(1).Trim())
            End If
        Next
        Console.ReadLine()


Thanks anyway ... >.>

a1a4a
Newbie Poster
18 posts since Dec 2010
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: