Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Strings and Arrays (easy 50 points)

Posted on 2001-06-21
8
Medium Priority
?
162 Views
Last Modified: 2010-05-18

I have a string that is something like "AAAA 9999" and all I'm interested in is the first 4 or 5  letters, I want to split at the whitespace.  I know the split function returns an array.  Isn't there a way to convert an array into a string in one line of code instead of a loop?

Note: I can't use Left() because the letters might be longer than 4 chars in some cases.

Thanks.
0
Comment
Question by:mudface061200
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:jrspano
ID: 6215191
dim s as string
s = join(array)
this will make the array concatinated together with no spaces between then

s = Join(array,"delimiter")
will join with delimiter between words
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6215195
oops you can't leave out the delimiter to get a concatinated string

ex
s = join(array,"")
0
 
LVL 18

Expert Comment

by:deighton
ID: 6215198
sNew = left(sString,instr(sString," ")-1)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Accepted Solution

by:
jrspano earned 200 total points
ID: 6215204
if you want all to the space just
dim holder as variant
dim s as string
dim t as string

t = "AAAA BBBB"
holder = split(t," ")
s = holder(0)
s now has AAAA in it
0
 
LVL 1

Author Comment

by:mudface061200
ID: 6215208
jrspano,

Maybe I wasn't clear, all I want is the first sequence of letters, I don't want the numbers at all, and I surely don't want to concatenate them.  So my desired result is a string of, in this example AAAA
0
 
LVL 1

Expert Comment

by:morgan_peat
ID: 6215226
What about InStr with Left?

    sBigStr = "AAAAAA 9999"    
    sShortStr = Left$(sBigStr, InStr(sBigStr, " ") - 1)
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6215236
the instr examples above will do that, my holder example above will also give you what you want.
0
 
LVL 1

Author Comment

by:mudface061200
ID: 6215246
I thought I already tried that, but trying your example worked.  Thanks to everyone who submitted comments, jrspano was the first to respond.

Thanks again
-m
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

721 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