![]() |
Help with getting first letter of a string
All I want is to see what the first letter of a string is. And then do an if then set of statements. I have found a few things out there, but nothing really really simple popped up. Anyone know a simple way to do it? ie: If feeder(0) = "F" Or feeder(0) = "R" Then Tsetup = 1 ElseIf feeder(0) = "S" Then Tsetup = 2 Else Tsetup = 3 End If -- McManCSU ------------------------------------------------------------------------ McManCSU's Profile: http://www.excelforum.com/member.php...o&userid=24379 View this thread: http://www.excelforum.com/showthread...hreadid=391933 |
Help with getting first letter of a string
I'm assuming feeder is a string. if so, this is an easy workaround: dim mychar as char = feeder if mychar = "F" Or mychar = "R" Then well, you have the rest from here. |
Help with getting first letter of a string
McManCSU,
Use Left(mystr, 1) to get the first letter of your string. So, dim mystr as string mystr = "Hello World" If Left(mystr, 1) = "H" Then.... Hope it helps Dave P.S., you can also change the 1 in the Left function to another number to return more of your string, like 5 gives you "Hello". Or you can use Right(...) as above to get the end of your string. "McManCSU" wrote: All I want is to see what the first letter of a string is. And then do an if then set of statements. I have found a few things out there, but nothing really really simple popped up. Anyone know a simple way to do it? ie: If feeder(0) = "F" Or feeder(0) = "R" Then Tsetup = 1 ElseIf feeder(0) = "S" Then Tsetup = 2 Else Tsetup = 3 End If -- McManCSU ------------------------------------------------------------------------ McManCSU's Profile: http://www.excelforum.com/member.php...o&userid=24379 View this thread: http://www.excelforum.com/showthread...hreadid=391933 |
Help with getting first letter of a string
Try using the Left function as shown below. "1" is the number of character
from the left of the field "feeder". Example: If left(feeder,1) = "F" Or left(feeder,1) = "R" Then Tsetup = 1 ElseIf left(feeder,1) = "S" Then "McManCSU" wrote: All I want is to see what the first letter of a string is. And then do an if then set of statements. I have found a few things out there, but nothing really really simple popped up. Anyone know a simple way to do it? ie: If feeder(0) = "F" Or feeder(0) = "R" Then Tsetup = 1 ElseIf feeder(0) = "S" Then Tsetup = 2 Else Tsetup = 3 End If -- McManCSU ------------------------------------------------------------------------ McManCSU's Profile: http://www.excelforum.com/member.php...o&userid=24379 View this thread: http://www.excelforum.com/showthread...hreadid=391933 |
All times are GMT +1. The time now is 04:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com