I am reading lines from a textfile. Each line in the textfile has the identical format:
textstring1:textstring2
The two strings are always separated by the : character.
I have the code to get textstring1, but because I'm a rookie, I can't figure out how to get textstring2.
See the code in bold, this is the line I need to get textstring2.
Private Sub CommandButton1_Click()
Dim FileName As String
Dim FilePath As String
Dim FSO As Object
Dim N As Long
Dim RegExp As Object
Dim Text As String
Dim TextFile As Object
Dim LineValue1 As String
Dim LineValue2 As String
FileName = "ocean_def.txt"
FilePath = "C:\pro\tyco_ocean"
Set RegExp = CreateObject("VBScript.RegExp")
RegExp.IgnoreCase = True
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TextFile = FSO.OpenTextFile(FileName, 1, False, -2)
N = 1
'Read the data line by line
Do While Not TextFile.AtEndOfStream
Text = TextFile.ReadLine
'Additional code to parse and compare goes here
'Look for the : character
If N = 1 Then
LineValue1 = Trim(Left(Text, InStr(1, Text, ":") - 1))
LineValue2 = Trim(Right(Text, InStr(1, Text, ":") - 1)) ' I need help with this line
a = LineValue1
b = LineValue2
Range("F29").Offset(0, 0) = a
Range("F30").Offset(0, 0) = b
End If
N = N + 1
Loop
TextFile.Close
End Sub
Excel 2000 VBA
Thank you for helping me.
Bookmarks