Results 1 to 16 of 16

Thread: How to separate the character of some word using Vb

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    19

    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

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    19

    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

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    19

    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.

  5. #5
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    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.

  6. #6
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    19

    Re: need help

    hmm dun have any other way for writing this code

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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

  9. #9
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    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?

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    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)

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    19

    Re: need urgent help

    thnx paul tht will help me..

  12. #12
    Addicted Member
    Join Date
    Nov 2011
    Posts
    129

    Re: need urgent help

    You and Barqs must be in the same class

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    19

    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

  14. #14
    Addicted Member
    Join Date
    Nov 2011
    Posts
    129

    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.

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Nov 2011
    Posts
    19

    Re: need urgent help

    ok thnx ... if i got any prob i will get back to you

  16. #16
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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
  •  



Click Here to Expand Forum to Full Width