Solved

what is the function which can ...

Posted on 2002-05-03
4
153 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
Comment Utility
Dim i As Integer
S = "Ray 14"
i = InStr(1, S, " ")
SS = Mid(S, 1, i - 1)
0
 
LVL 28

Expert Comment

by:vinnyd79
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 38
Excel Vlookup to move data back to source. 4 73
MS Access - Capture pressed key onclick 4 21
Copy a row 12 52
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now