• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

what is the function which can ...

Hi,

if S = "Ray 14" , are there any VB function makes me, by using it, let SS = "Ray"
notes: i cannot use (Left) function because S could be more than 3 letters

ex:
Dim S as string, SS as string
S = "Ray  14"
SS = something(S)

by runinng this code : SS = "Ray"

I look forward your code and help.

Thanks
Ray14
0
ray14
Asked:
ray14
  • 2
1 Solution
 
RichWCommented:
Dim i As Integer
S = "Ray 14"
i = InStr(1, S, " ")
SS = Mid(S, 1, i - 1)
0
 
vinnyd79Commented:
if your using vb6 you could use the split function

Dim S As String
Dim SS() As String
S = "Ray  14"
SS = Split(S, " ")
MsgBox SS(0)
0
 
RichWCommented:
I would've used Split, but the asker said he wanted SS="Ray". 6 of one, half a dozen of the other.

Cheers,

RichW




0
 
vbWayneCommented:
You can still use the split as vinnyd79 has indicated.

Dim S As String
Dim RR As Variant
S = "Ray  14"
RR = Split(S)
SS = RR(0)  ' SS = Ray

Msgbox SS

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now