Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible in Visual Basic to pull a single character from a certain line?

Status
Not open for further replies.

krsupinger

Programmer
Jul 10, 2014
2
US
I have been working on this problem for the last couple of days and have not found the answer that I need anywhere on the internet in VB.
I am now wondering if it is even possible.
I am needing to write a macro that is going to do a few things but the one that I am having trouble with is how to have the macro check the first character of the 9th line and see if it is a ">".
I have not had any trouble with the testing etc of the other parts of the macro.
I have found a few places that talk about doing something similar in C## and Java but not in VB.
If anyone can help and let me know if this is possible I would greatly appreciate it.
Current code for that I have for this is
If (Left(ReadLine(9), 1)) = ">" Then
.Transmit "P" & CR
ElseIf (Left(ReadLine(9), 1)) <> ">" Then
.Transmit CR
End If

 
PS.I know that the Left command does not work after doing some more research.
 
Is this a VB/VBA question or a VB.NET question? It's hard to tell since you are referring to macros and using 1-based arrays. Is the "9th line" index element 8 or 9?

Assuming ReadLine is an array of the lines you're processing, try the following:
Code:
If (ReadLine.Length >= 9 AndAlso ReadLine(8).Length > 0 AndAlso ReadLine(8)(0) = ">"c) Then
    .Transmit "P" & CR
Else
    .Transmit CR
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top