How to Identify & Extract Relations From Text Applications
Microsoft has functions that let you import, identify and extract relations from the text stored in the application's files. You use the Microsoft Visual Basic language to parse this information and display it to your custom software users. The "InStr" function extracts text if the identified string is stored in the file. You use this feature to find data stored in external text applications.
Instructions
-
-
1
Open the Visual Studio software, and open the desktop project you want to edit. Double-click the source code file used to read the text files.
-
2
Open the file and import the file into a VB variable. The following code reads the "myfile.txt" file:
Dim read As String
read = My.Computer.FileSystem.ReadAllText("C:\myfile.txt") -
-
3
Identify if a string exists in the file. The "InStr" function returns "1" if the string exists. If not, the return value is "0." Use the following code to search for "my string" in the file:
Dim exists As Integer
exists = InStr(read, "my string") -
4
Send a message to the user to display a confirmation if the string exists. The following function displays a message to the user:
If (exists) Then
MsgBox "The string exists"
ElseIf
MsgBox "The string does not exist"
End If
-
1