473,385 Members | 1,930 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,385 software developers and data experts.

Is this the fastest way

Hi,
I need to split a string by character so instead of

Dim str() as str
Dim sStr as string = "abcdef"

str(0) = sStr.substring(0,1)
str(1) = sStr.substring(1,2)
str(2) = sStr.substring(2,3)
str(3) = sStr.substring(3,4)
str(4) = sStr.substring(4,5)

I have

Dim sStr as string = "abcdef"
Dim chrs(5) as Char

sStr.CopyTo(0,chrs,0,6)

'To test
msgbox(chrs(0).toString)

Which is the better way?

Thanks

Jun 23 '06 #1
4 1078
How about yourString.ToCharArray() ?

Dan Manges

Chris wrote:
Hi,
I need to split a string by character
[snip]
Which is the better way?

Jun 23 '06 #2
Chris,

Why not use that string direct as an immutable array of char

Dim sStr as string = "abcdef"
dim mychar as char = sStr(3) 'to get the d.

Cor

"Chris" <Ch***@discussions.microsoft.com> schreef in bericht
news:A3**********************************@microsof t.com...
Hi,
I need to split a string by character so instead of

Dim str() as str
Dim sStr as string = "abcdef"

str(0) = sStr.substring(0,1)
str(1) = sStr.substring(1,2)
str(2) = sStr.substring(2,3)
str(3) = sStr.substring(3,4)
str(4) = sStr.substring(4,5)

I have

Dim sStr as string = "abcdef"
Dim chrs(5) as Char

sStr.CopyTo(0,chrs,0,6)

'To test
msgbox(chrs(0).toString)

Which is the better way?

Thanks

Jun 23 '06 #3
But then I would need to have multiple Dim statements to get the individual
values like

dim mychar as char = sStr(0)
dim mychar as char = sStr(1)
dim mychar as char = sStr(2)
dim mychar as char = sStr(3)
dim mychar as char = sStr(4)
dim mychar as char = sStr(5)

No?

"Cor Ligthert [MVP]" wrote:
Chris,

Why not use that string direct as an immutable array of char

Dim sStr as string = "abcdef"
dim mychar as char = sStr(3) 'to get the d.

Cor

"Chris" <Ch***@discussions.microsoft.com> schreef in bericht
news:A3**********************************@microsof t.com...
Hi,
I need to split a string by character so instead of

Dim str() as str
Dim sStr as string = "abcdef"

str(0) = sStr.substring(0,1)
str(1) = sStr.substring(1,2)
str(2) = sStr.substring(2,3)
str(3) = sStr.substring(3,4)
str(4) = sStr.substring(4,5)

I have

Dim sStr as string = "abcdef"
Dim chrs(5) as Char

sStr.CopyTo(0,chrs,0,6)

'To test
msgbox(chrs(0).toString)

Which is the better way?

Thanks


Jun 23 '06 #4
Why would you put the values in separate variables? What are you going
to use it for?

Chris wrote:
But then I would need to have multiple Dim statements to get the individual
values like

dim mychar as char = sStr(0)
dim mychar as char = sStr(1)
dim mychar as char = sStr(2)
dim mychar as char = sStr(3)
dim mychar as char = sStr(4)
dim mychar as char = sStr(5)

No?

"Cor Ligthert [MVP]" wrote:
Chris,

Why not use that string direct as an immutable array of char

Dim sStr as string = "abcdef"
dim mychar as char = sStr(3) 'to get the d.

Cor

"Chris" <Ch***@discussions.microsoft.com> schreef in bericht
news:A3**********************************@microsof t.com...
Hi,
I need to split a string by character so instead of

Dim str() as str
Dim sStr as string = "abcdef"

str(0) = sStr.substring(0,1)
str(1) = sStr.substring(1,2)
str(2) = sStr.substring(2,3)
str(3) = sStr.substring(3,4)
str(4) = sStr.substring(4,5)

I have

Dim sStr as string = "abcdef"
Dim chrs(5) as Char

sStr.CopyTo(0,chrs,0,6)

'To test
msgbox(chrs(0).toString)

Which is the better way?

Thanks

Jun 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Simon | last post by:
Hi, If I have a string, (variable len), and I am looking for the first position of one char in array starting from position 'x' For example, // the 'haystack' $string = "PHP is great,...
9
by: Rune Strand | last post by:
Hi, If I have a lot of integers and want do something with each digit as integer, what is the fastest way to get there? Eg. Make 12345 into an iterable object, like or "12345" (Btw: What is...
6
by: Neal D. Becker | last post by:
I need a fairly small lookup table, and I'm wondering which data python data structure would be fastest. I could use a list, tuple, dictionary, numeric array, or maybe plain python array. The...
11
by: DraguVaso | last post by:
Hi, I should use XML to synchronize the data from different (VB.NET) applications, and I was just wondering which Overloads of these functions ( ReadXmlSchema, ReadXml and WriteXml) goes the...
6
by: Jonathan | last post by:
I am hoping that someone more experienced than myself can point me towards what might be the fastest data lookup method to use for storing ip addresses. My situation is that I will need to maintain...
4
by: laurenq uantrell | last post by:
I am trying to determine which of three stored procedure designs are fastest in the Query Analyzer: One query is a straight SELECT query with all desired rows and a dozen (tblName.RowName =...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
6
by: Klaas Vantournhout | last post by:
Hi, I have a question, which is just out of interest. What is the fastest way to do an odd/even check with c++ and if needed assembler. Assume n is an unsigned integer like type (unsigned...
22
by: SETT Programming Contest | last post by:
The SETT Programming Contest: The fastest set<Timplementation Write the fastest set<Timplementation using only standard C++/C. Ideally it should have the same interface like std::set. At least...
0
by: dantz | last post by:
After reading all of the materials in msdn about interprocess communication now I am confused. I hope someone can give me some enlightment. I am developing a multithreaded client-server...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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...

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.