Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change 3 letter text string to a number string | Excel Discussion (Misc queries) | |||
selecting the last letter in a string | New Users to Excel | |||
Count letter string, e.g. h/EL/p | Excel Worksheet Functions | |||
How to count the match letter within a string? | Excel Discussion (Misc queries) | |||
Remove the last letter from a string! | Excel Programming |