-
Ok what it's suppose to do is look at a file, if the file contains 11 charcters then write the first 5 to label1.caption, if it contains 10 charcters write the first 4 to label1.caption.
Dim sfirst
Open "\flag\ini\session1\mon.ini" For Input As #9
Line Input #9, sfirst
if sfirst = left(sfirst, 11) then
label1.caption = left(sfirst, 5)
close #9
else
label1.caption = left (first, 4)
close #9
end if
-
Typo
i know that last first is suppose to be sfirst.
-
Use the "Len" function to return the length of the string.
Code:
Dim sfirst as String
Open "\flag\ini\session1\mon.ini" For Input As #9
Line Input #9, sfirst
if len(sfirst) = 11 then
label1.caption = left$(sfirst, 5)
close #9
Else
label1.caption = left (sfirst, 4)
close #9
End if
I am not sure if this will work though, as you may have a vbCrLf on the end of the string. If this is the case you can remove it, or add + 2 to the length compare, so it is compared to 13.
-
Hi.
Well, you didn't really say what the code was doing wrong.
Maybe you can try this:
Open "C:\a.txt" for input as #1
Line Input #1, strText
If Len(strText) = 11 Then
Label1.Caption = Left(strText,5)
Close #1
Else
Label1.Caption = Left(strText,4)
Close #1
End If
HOPE THIS HELPS!!
-
Thanks a lot guys
The problem was I was going about it the wrong way. I needed that "Len" command, doing everything left just didnt work. Thanks a lot!~