Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
selecting the last letter in a string csr1176 New Users to Excel 2 November 22nd 07 07:15 PM
Count letter string, e.g. h/EL/p Lee Excel Worksheet Functions 16 September 4th 07 11:57 AM
How to count the match letter within a string? Eric Excel Discussion (Misc queries) 7 August 22nd 07 03:43 AM
Remove the last letter from a string! Mannyluk Excel Programming 1 March 21st 05 03:45 PM


All times are GMT +1. The time now is 02:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"