TimSweet220
asked on
Trim a field and check for trimmed value
I have a field in a vb.net app that I need to check part of it to see what it contains.
Can I use the TRIM function to cut out all be the first three charactors or should it be LEN
sample
IF trim(field1, 3) = "IMG" then
DoStuf()
end If
Thanks in advance
Can I use the TRIM function to cut out all be the first three charactors or should it be LEN
sample
IF trim(field1, 3) = "IMG" then
DoStuf()
end If
Thanks in advance
Tim, you can use trim function to trim empty spaces not to manipulate the string
try using Right() function:
IF Right(field1, 3) = "IMG" then
DoStuf()
end If
IF Right(field1, 3) = "IMG" then
DoStuf()
end If
sorry, I mean Left():
try using Right() function:
IF Left(field1, 3) = "IMG" then
DoStuf()
end If
try using Right() function:
IF Left(field1, 3) = "IMG" then
DoStuf()
end If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Substring will work too:
If field1.Substring(0, 3) ="IMG" then
end if
If field1.Substring(0, 3) ="IMG" then
end if
ah, you wanted the first 3 characters ...
Dim Field1 As String = "IMGX1"
Dim Trimmed As String = Field1.Substring(0, 3)
Debug.Print(Trimmed)
'Will display = IMG
@YZlat : 'Left' isn't strictly .net though is it ...
Dim Field1 As String = "IMGX1"
Dim Trimmed As String = Field1.Substring(0, 3)
Debug.Print(Trimmed)
'Will display = IMG
@YZlat : 'Left' isn't strictly .net though is it ...
well, I gave other examples too, in case Left won't work for him.
By the way, in your last example you repeated what I've said already...
By the way, in your last example you repeated what I've said already...
probably be 3 seconds ... ;)
otheriwse I would have seen it.
otheriwse I would have seen it.
Dim Field1 As String = "IMGX1"
Dim Trimmed As String = Field1.Substring(3)
Debug.Print(Trimmed)
'Will display = X1