I am somewhat new to VB and trying to figure out how to accomplish my task. And who better to ask then the people who know.
What I am trying to accomplish is to search a txt file and locate a specific string and then assign the words that follow into labels. Here is a sample of the txt file.
HW Ref Point Name Device Type Point Type Custom Label
2-1 M1-1-0 PHOTO SMOKE ELEVATOR 3 PIT M1-1
2-2 M1-2-0 HEAT HEAT ELEVATOR 3 PIT M1-2
2-3 M1-3-0 PHOTO SMOKE ELEVATOR 4 PIT M1-3
2-4 M1-4-0 HEAT HEAT ELEVATOR 4 PIT M1-4
2-5 M1-5-0 HEAT HEAT ELEVATOR 1 PIT M1-5
2-6 M1-6-0 PHOTO SMOKE ELEVATOR 1 PIT M1-6
2-7 M1-7-0 HEAT HEAT ELEVATOR 2 PIT M1-7
2-8 M1-8-0 PHOTO SMOKE ELEVATOR 2 PIT M1-8
2-9 M1-9-0 ADRPUL PULL GFL CONCIERGE DESK M1-9
In my form i have labels that will be assigned for each device type, point type and the custom label.
Is there a way to search the text and locate M1-1-0 and then have it assign PHOTO to a label, lets say its named M1_1DT. Same for Point Type(M1_1PT) and the custom label(M1_1CL). I think once I understand how to accomplish this i should be able to repeat it to assign other text to their corresponding labels.
My txt file is the output of another program so there is no way I know of to be able to easily put it into a database.
Any help would be much appreciated, due to the fact that I'm pretty stumped on this. The most i have been able to do is to make a form be able to locate a string and display the number of times it is found in a message box. If this is not even the correct path feel free to let me know. Here is what i have so far to accomplish that.
What I am trying to accomplish is to search a txt file and locate a specific string and then assign the words that follow into labels. Here is a sample of the txt file.
HW Ref Point Name Device Type Point Type Custom Label
2-1 M1-1-0 PHOTO SMOKE ELEVATOR 3 PIT M1-1
2-2 M1-2-0 HEAT HEAT ELEVATOR 3 PIT M1-2
2-3 M1-3-0 PHOTO SMOKE ELEVATOR 4 PIT M1-3
2-4 M1-4-0 HEAT HEAT ELEVATOR 4 PIT M1-4
2-5 M1-5-0 HEAT HEAT ELEVATOR 1 PIT M1-5
2-6 M1-6-0 PHOTO SMOKE ELEVATOR 1 PIT M1-6
2-7 M1-7-0 HEAT HEAT ELEVATOR 2 PIT M1-7
2-8 M1-8-0 PHOTO SMOKE ELEVATOR 2 PIT M1-8
2-9 M1-9-0 ADRPUL PULL GFL CONCIERGE DESK M1-9
In my form i have labels that will be assigned for each device type, point type and the custom label.
Is there a way to search the text and locate M1-1-0 and then have it assign PHOTO to a label, lets say its named M1_1DT. Same for Point Type(M1_1PT) and the custom label(M1_1CL). I think once I understand how to accomplish this i should be able to repeat it to assign other text to their corresponding labels.
My txt file is the output of another program so there is no way I know of to be able to easily put it into a database.
Any help would be much appreciated, due to the fact that I'm pretty stumped on this. The most i have been able to do is to make a form be able to locate a string and display the number of times it is found in a message box. If this is not even the correct path feel free to let me know. Here is what i have so far to accomplish that.
Code:
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("C:\preview1.txt")
TextBox1.Text = fileReader
Dim regex As New System.Text.RegularExpressions.Regex(" M1-1-0 ", RegexOptions.IgnoreCase Or RegexOptions.Singleline)
Dim regexMatches As MatchCollection = regex.Matches(fileReader)
MessageBox.Show(regexMatches.Count)
End Sub
End Class