Solved

what is the function which can ...

Posted on 2002-05-03
4
155 Views
Last Modified: 2010-05-02
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
Comment
Question by:ray14
  • 2
4 Comments
 
LVL 4

Expert Comment

by:RichW
ID: 6989279
Dim i As Integer
S = "Ray 14"
i = InStr(1, S, " ")
SS = Mid(S, 1, i - 1)
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6989288
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
 
LVL 4

Expert Comment

by:RichW
ID: 6989307
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
 
LVL 1

Accepted Solution

by:
vbWayne earned 50 total points
ID: 6990046
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

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question