473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Splitting a string into separate strings

2
Hey I was wondering how do I go about doing this.

Expand|Select|Wrap|Line Numbers
  1. strCommand = readCommand("aaa;sss;ddd", 1)
  2. MsgBox (strCommand)
  3.  
Expand|Select|Wrap|Line Numbers
  1. Public Function readCommand(str As String, position As Integer) As String
  2. If position = 1 Then
  3.     str = Split(str, ";")
  4.     readCommand = str
  5. End If
  6.  
  7. End Function
  8.  
I want it such that if the position parameter passed to the readCommand function is 1, the first part of the string "aaa" will be returned, and so on.
the code above gave a type mismatch, I am guessing its because the Split method is only for arrays? Any suggestions?

Thanks!
Oct 22 '08 #1
1 1225
QVeen72
1,445 Expert 1GB
Hi,

Yes, the Split Result Need to Be Assigned to An Array...
Change your Function Like this :

Expand|Select|Wrap|Line Numbers
  1. Public Function readCommand(ByVal Mystr As String, ByVal position As Integer) As String
  2.     Dim TArr
  3.     TArr = Split(Mystr, ";")
  4.     readCommand =""
  5.     '
  6.     On Error Resume Next  ' In Case Position is Out Of Array Range..
  7.     readCommand = TArr(Position-1)
  8. End Function
  9.  
  10.  
Regards
Veena
Oct 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Mark Light | last post by:
Hi, I have a string e.g. 'C6 H12 O6' that I wish to split up to give 2 strings 'C H O' and '6 12 6'. I have played with string.split() and the re module - but can't quite get there. Any help...
3
by: Piet | last post by:
Hello, I have a very strange problem with regular expressions. The problem consists of analyzing the properties of columns of a MySQL database. When I request the column type, I get back a string...
9
by: Dr. StrangeLove | last post by:
Greetings, Let say we want to split column 'list' in table lists into separate rows using the comma as the delimiter. Table lists id list 1 aa,bbb,c 2 e,f,gggg,hh 3 ii,kk 4 m
2
by: Trint Smith | last post by:
Ok, My program has been formating .txt files for input into sql server and ran into a problem...the .txt is an export from an accounting package and is only supposed to contain comas (,) between...
20
by: Opettaja | last post by:
I am new to c# and I am currently trying to make a program to retrieve Battlefield 2 game stats from the gamespy servers. I have got it so I can retrieve the data but I do not know how to cut up...
7
by: Matik | last post by:
Hi to everyone, My problem is, that I'm not so quite sure, which way should I go. The user is inputing by second part application a long string (let's say 128 characters), which are separated...
12
by: John | last post by:
Hi I have a multi-line address field which has each line separated by CRLF. How can I split this field into individual strings using crlf as separator? Thanks Regards
29
by: Andrea | last post by:
I want to write a program that: char * strplit(char* str1, char *str2, char * stroriginal,int split_point) that take stroriginal and split in the split_point element of the string the string...
2
by: shadow_ | last post by:
Hi i m new at C and trying to write a parser and a string class. Basicly program will read data from file and splits it into lines then lines to words. i used strtok function for splitting data to...
4
by: techusky | last post by:
I am making a website for a newspaper, and I am having difficulty figuring out how to take a string (the body of an article) and break it up into three new strings so that I can display them in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.