|
-
Nov 18th, 2011, 02:09 PM
#1
Thread Starter
Junior Member
How to separate the character of some word using Vb
hello all,
i want an urgent help from you all people for my assignment . the assignment is to separate the consecutive characters in whole word . (Hint- Ascii)
he gave us a example Student - st de
please help me asap
-
Nov 18th, 2011, 02:17 PM
#2
Re: How to separate the character of some word using Vb
Hi eddy, welcome to the forum. Unfortunately your question is too unclear to answer. If you "separate consecutive characters" in the word student you would end up with s, t, u, d, e, n and t. So how are you supposed to get st de?
BB
-
Nov 18th, 2011, 02:19 PM
#3
Thread Starter
Junior Member
Re: How to separate the character of some word using Vb
yeah mine will come like s,t,d,e only these are the consecutive no. in student
-
Nov 18th, 2011, 02:25 PM
#4
Thread Starter
Junior Member
Re: How to separate the character of some word using Vb
application that will determine if a word entered has consecutive letters in the alphabet as a
substring of itself. Three examples are THIRSTY, AFGHANISTAN, and STUDENT. The D and E in STUDENT
and H and I in THIRSTY are also consecutive.
To do this, you should use nested loops. The outer loop loops through every character. The inner loop
will loop while the end of the word has not been reached and the next letter(s) is consecutive.
Your program should count the number of consecutive letters in the word and display it to the user.
Watch out for words like STUDENT with multiple sets of consecutive letters! If the word STUDENT is
entered, for example, show me that both STU and DE are consecutive, and that STU is 3 consecutive
letters. Do not just check for the next letter – check the rest of the word. It is OK if your program
catches both STU and TU or ST in STUDENT as consecutive in turn.
Note that letters have numeric values called ASCII. To get the ASCII value of a letter (not a word!), type
ASC(letter) where letter is the character you want the value for. The value of “A” is 65, and the value of
“B” is 66, for example. This should make the comparison nice and simple. Be careful though – this is
one example where VB.NET is case-sensitive. Lowercase “a” is 97! You should convert the entire word
to a single case using the String functions.
-
Nov 18th, 2011, 02:39 PM
#5
Frenzied Member
Re: need help
Lol your classmate was here already...
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Nov 18th, 2011, 02:39 PM
#6
Frenzied Member
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Nov 18th, 2011, 02:44 PM
#7
Thread Starter
Junior Member
Re: need help
hmm dun have any other way for writing this code
-
Nov 18th, 2011, 03:59 PM
#8
Re: How to separate the character of some word using Vb
How many threads on this subject are there?
I was going to write more, but it was all explained in the bottom part of the problem. In fact, whoever wrote that pretty nearly told you how to do it. The only thing missing is that you have to have a loop. They covered the fact that you need to use ToUpper or ToLower to convert to a single case, and they covered the bit about using ASC to get the numeric value for the character, so you can compare it to the next letter. What is left? Show us some code, and tell us what you are having trouble with.
My usual boring signature: Nothing
 
-
Nov 18th, 2011, 05:15 PM
#9
Re: need urgent help
Sounds like home work. Not to mention seen exact same "student" question in recent days. This forum works on a guiding basis. You have shown no work so why would any one just write it for you?
Also your title is not descriptive. Why is your post more urgent then other users?
-
Nov 18th, 2011, 05:48 PM
#10
Re: need urgent help
here's how:
- create a new list(of string) to hold the consecutive letter string occurrences
- create a string variable called consecutiveString + initialize it as the first char in your input string
- create a loop from 0 To [inputString].Length - 2
- in your loop, test: If Asc([inputString].Substring(x, 1)) = Asc([inputString].Substring(x + 1, 1)) - 1
- if yes then add [inputString].Substring(x + 1, 1) to your consecutiveString variable
- if no, + consecutiveString.length > 1, add consecutiveString to the list(of string). set consecutiveString = [inputString].Substring(x + 1, 1)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 18th, 2011, 06:00 PM
#11
Thread Starter
Junior Member
Re: need urgent help
thnx paul tht will help me..
-
Nov 18th, 2011, 06:04 PM
#12
Addicted Member
Re: need urgent help
You and Barqs must be in the same class
-
Nov 18th, 2011, 06:12 PM
#13
Thread Starter
Junior Member
Re: need urgent help
lol yeah but i dont know who is that guy ,,,, i saw that program but could nt able to understand tht last part.... will u letme know how you did that
-
Nov 18th, 2011, 06:37 PM
#14
Addicted Member
Re: need urgent help
It is pretty much the same as what .paul. explained in his reply. I just used a string variable to hold the consecutive letters, then when the letters were not consecutive, I dumped the string to the listbox. Or if the letters were consecutive through the end of the inputstring, then I dump the string to the listbox.
For others reading this, we are referring to this thread.
-
Nov 18th, 2011, 06:39 PM
#15
Thread Starter
Junior Member
Re: need urgent help
ok thnx ... if i got any prob i will get back to you
-
Nov 19th, 2011, 03:10 AM
#16
Re: How to separate the character of some word using Vb
Duplicate threads merged - please post each question (or variation of it) only once.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|