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

Split a String - not sure how to ask the question

I am in a learning curve right now, and want to become well aquanted
with VB.NET. So, I have two questions. 1 is technial the other is
resource related.

1. I need to strip a single character from a string. I will explain
why. I am creating a page that will add users to Active Directory. I
collect the FirstName value (based on a pre-composed Excel
spreadsheet) and want to strip just the first initial so I can create
the sAMAccountName based on the users first initial.

I assume I will use the string.split function somehow, but I cannot
seem to populate my array with each of the characters of the FirstName
string.

So far I have come up with

stringarray = strfirstname.split(????? - this is where I am confused)
2. What is a recommended reference book for VB.NET. There are many,
but I want one that other's recommend. I am fairly new to VB.NET
programming.


THANKS!!!
Nov 20 '05 #1
8 10188
Cor
Hi "J Stoodley"
stringarray = strfirstname.split(????? - this is where I am confused) first position of a string
x=strfirstname.substring(0,1)' place and lenght

where I in this example asume that the first inital is on the first
position.

You can use in VB.net a lot of string commanodo. To call some
The microsoft.visualbasic functions, the system.string member, the reg
expressions..................
Normaly you use or the microsoft visual.basic functions or the system.string
members.
The first are like VB6 and earlier, the later more like all C, J and
javascripts.
VB functions are (Mid, right, left etc)
String members (tolower, substring, indexof)
2. What is a recommended reference book for VB.NET. There are many,
but I want one that other's recommend. I am fairly new to VB.NET
programming.

I did not read a book about VB.net .
The new walkthougs from Microsoft become better and better.
But I think you will get other advises too.

I hope this helps
Cor
Nov 20 '05 #2
Im not sue if this is what you want ?

Dim strings() As Char

Dim str As String = txtIn.Text

strings = str.ToCharArray

txtOut.Text = strings(0).ToString



"J Stoodley" <js*******@canada.com> wrote in message
news:84**************************@posting.google.c om...
I am in a learning curve right now, and want to become well aquanted
with VB.NET. So, I have two questions. 1 is technial the other is
resource related.

1. I need to strip a single character from a string. I will explain
why. I am creating a page that will add users to Active Directory. I
collect the FirstName value (based on a pre-composed Excel
spreadsheet) and want to strip just the first initial so I can create
the sAMAccountName based on the users first initial.

I assume I will use the string.split function somehow, but I cannot
seem to populate my array with each of the characters of the FirstName
string.

So far I have come up with

stringarray = strfirstname.split(????? - this is where I am confused)
2. What is a recommended reference book for VB.NET. There are many,
but I want one that other's recommend. I am fairly new to VB.NET
programming.


THANKS!!!

Nov 20 '05 #3
Visual Basic.NET step by step ( microsoft press )

"J Stoodley" <js*******@canada.com> wrote in message
news:84**************************@posting.google.c om...
I am in a learning curve right now, and want to become well aquanted
with VB.NET. So, I have two questions. 1 is technial the other is
resource related.

1. I need to strip a single character from a string. I will explain
why. I am creating a page that will add users to Active Directory. I
collect the FirstName value (based on a pre-composed Excel
spreadsheet) and want to strip just the first initial so I can create
the sAMAccountName based on the users first initial.

I assume I will use the string.split function somehow, but I cannot
seem to populate my array with each of the characters of the FirstName
string.

So far I have come up with

stringarray = strfirstname.split(????? - this is where I am confused)
2. What is a recommended reference book for VB.NET. There are many,
but I want one that other's recommend. I am fairly new to VB.NET
programming.


THANKS!!!

Nov 20 '05 #4


Hi Stoodley--

Answer to Question 1...

....this code works and MAY do what you need (if I have understood your
question correctly)...

Private Sub btnTestParsing01_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles btnTestParsing01.Click

Dim strValue As String
Dim intIndex As Integer
Dim objList As ArrayList

'Fill string value.
strValue = "AName"
objList = New ArrayList()

'Fill array with characters.
For intIndex = 0 To strValue.Length - 1
objList.Add(strValue.Chars(intIndex))
Next

'Print characters from array.
For intIndex = 0 To objList.Count - 1
Response.Write("objList.Item(intIndex).ToString() = " _
& objList.Item(intIndex).ToString())
Response.Write("<br />")
Next

End Sub

Answer to Question (2)...

There are a lot of factors here, such as learning style, preferences, time
spent reading, experience, and so on. That said, here is a general rule.

First, assuming one is totally new to language X and to programming, then
one should read a beginner's book, from start to finish. I recommend
something like "Sam's Teach Yourself X in 21 Days" or "Wrox's Beginning X".
After you have this first book, you will KNOW how to pick out you next one.


HTH.

--Mark

"J Stoodley" <js*******@canada.com> wrote in message
news:84**************************@posting.google.c om...
I am in a learning curve right now, and want to become well aquanted
with VB.NET. So, I have two questions. 1 is technial the other is
resource related.

1. I need to strip a single character from a string. I will explain
why. I am creating a page that will add users to Active Directory. I
collect the FirstName value (based on a pre-composed Excel
spreadsheet) and want to strip just the first initial so I can create
the sAMAccountName based on the users first initial.

I assume I will use the string.split function somehow, but I cannot
seem to populate my array with each of the characters of the FirstName
string.

So far I have come up with

stringarray = strfirstname.split(????? - this is where I am confused)
2. What is a recommended reference book for VB.NET. There are many,
but I want one that other's recommend. I am fairly new to VB.NET
programming.


THANKS!!!
Nov 20 '05 #5
you can do it a bunch of ways, but one easy one would be Dim s as String =
Microsoft.VisualBasic.Left(FirstName, 1) 'Will return the first character in
the string

Split will split it based on a delimitter, but if you don't need the other
values, use either Left as above or Substring

2) Visual Basic .NET Core Reference by Fransesco Balena is excellent, and
Coding Techniques for Visual Basic .NET by John Connell is another great on.
On DataAccess, David Sceppa's ADO.NET Core Reference is a must have, and
anything that Bill Vaughn writes should probably be in your library.

Cheers,

Bill
"J Stoodley" <js*******@canada.com> wrote in message
news:84**************************@posting.google.c om...
I am in a learning curve right now, and want to become well aquanted
with VB.NET. So, I have two questions. 1 is technial the other is
resource related.

1. I need to strip a single character from a string. I will explain
why. I am creating a page that will add users to Active Directory. I
collect the FirstName value (based on a pre-composed Excel
spreadsheet) and want to strip just the first initial so I can create
the sAMAccountName based on the users first initial.

I assume I will use the string.split function somehow, but I cannot
seem to populate my array with each of the characters of the FirstName
string.

So far I have come up with

stringarray = strfirstname.split(????? - this is where I am confused)
2. What is a recommended reference book for VB.NET. There are many,
but I want one that other's recommend. I am fairly new to VB.NET
programming.


THANKS!!!

Nov 20 '05 #6
WOW, I cannot beleive the number of replies I recevied already.
THANKS!!!

I figured out my solution, I think the most efficient way, using a
substring.

----

Thanks to everyone for the responses. I have been dabbling in
programming for years now. So it's hard for me to rate myself. I still
feel like a novice :)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7
Hi Jeff,

.NET makes <everybody> feel like a novice for a while. You've just gotta
climb that hill. :-)

Regards,
Fergus
Nov 20 '05 #8
One Handed Man [ OHM ] wrote:
Visual Basic.NET step by step ( microsoft press )

"J Stoodley" <js*******@canada.com> wrote in message
news:84**************************@posting.google.c om...
I am in a learning curve right now, and want to become well aquanted
with VB.NET. So, I have two questions. 1 is technial the other is
resource related.

1. I need to strip a single character from a string. I will explain
why. I am creating a page that will add users to Active Directory. I
collect the FirstName value (based on a pre-composed Excel
spreadsheet) and want to strip just the first initial so I can create
the sAMAccountName based on the users first initial.

I assume I will use the string.split function somehow, but I cannot
seem to populate my array with each of the characters of the FirstName
string.

So far I have come up with

stringarray = strfirstname.split(????? - this is where I am confused)
2. What is a recommended reference book for VB.NET. There are many,
but I want one that other's recommend. I am fairly new to VB.NET
programming.


THANKS!!!


This might help..

http://www.lowth.com/books/topic/dotnet - the "top 20" .NET books as defined
by Amazon's "sales ranking".

Updated daily.

Chris

--
Real address: chris at lowth dot sea oh em.
World's first wrist-watch PDA with Palm OS, exclusively
from Amazon.com. http://www.lowth.com/shop/wrist_pda
Nov 20 '05 #9

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

Similar topics

3
by: alexk | last post by:
I've a simple question. Why the following: words = "123#@$#$@^% wordB#@$".split('~`!@#$%^&*()_+-={},./') doesn't work? The length of the result vector is 1. I'm using ActivePython 2.4 Alex
2
by: middletree | last post by:
Not really sure what the problem is, perhaps I am using split wrong. Page should get form fields form previous page and some of them will go into a tabel called Personal. Other items, to resolve...
6
by: Senthil | last post by:
Code ---------------------- string Line = "\"A\",\"B\",\"C\",\"D\""; string Line2 = Line.Replace("\",\"","\"\",\"\""); string CSVColumns = Line2.Split("\",\"".ToCharArray());
3
by: John Salerno | last post by:
This is an example in the book I'm reading: string fullName = " Edward C Koop "; fullName = fullName.Trim(); string names = fullName.Split(' '); string firstName = names; //...
3
by: Andi Twine | last post by:
Hi all, I really hope someone here can help ! I have designed and built an ASP.NET web service with Visual Studio .NET. The web service outputs some dummy XML data when its called with some...
5
by: KC | last post by:
Can I do a split() on a string where the delimiter is one or more space characters? I have a string with spaces between the numbers but I don't know how many. You can do this easy in Perl, but...
4
by: Steven D'Aprano | last post by:
I'm having problems passing a default value to the maxsplit argument of str.split. I'm trying to write a function which acts as a wrapper to split, something like this: def mysplit(S, sep=None,...
7
by: AMP | last post by:
Hello, I am trying to split a string at the newline and this doesnt work: String Channel = FileName.Split("\r"); What am I doing wrong? Thanks Mike
1
by: mad.scientist.jr | last post by:
I am working in C# ASP.NET framework 1.1 and for some reason Regex.Split isn't working as expected. When trying to split a string, Split is returning an array with the entire string in element ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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...
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...

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.