| | |
Help with Reverse Problem
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
In Visual Basic 2008 Express edition: Create a new string replacing the order of the words, from last one to the first one and show it in a text box
Example:
Input: “This is an example”
Output: “example an is This”
I know theres a function to reverse the letters (StrReverse), but the order of the words? Please someone help me out.
Example:
Input: “This is an example”
Output: “example an is This”
I know theres a function to reverse the letters (StrReverse), but the order of the words? Please someone help me out.
•
•
Join Date: Sep 2009
Posts: 42
Reputation:
Solved Threads: 5
0
#2 21 Days Ago
I don't know if there are indexing routines, but you can set your starting position at 0. while it is less than the length of the string and the character at that position is blank go to the next starting position
set your ending length to 0 and while the length + position character are not blank and not past the end of the string you increment the length by 1. That identifies the length and position of the next word that you insert into a string array and increment the array by one.
Repeat that process using the new starting position until all the words are added to the array. Initalize a string with the last word in the array, from the next to last word to the beginning add a blank and that word to the string. This will not retain multiple blanks in the reversed string.
set your ending length to 0 and while the length + position character are not blank and not past the end of the string you increment the length by 1. That identifies the length and position of the next word that you insert into a string array and increment the array by one.
Repeat that process using the new starting position until all the words are added to the array. Initalize a string with the last word in the array, from the next to last word to the beginning add a blank and that word to the string. This will not retain multiple blanks in the reversed string.
1
#3 21 Days Ago
Try it,
VB.NET Syntax (Toggle Plain Text)
Dim s As String = "This is an example" s = String.Join(" ", s.Split(" ").ToArray().Reverse().ToArray())
Failure is not fatal, but failure to change might be. - John Wooden
![]() |
Similar Threads
- Sony Vaio Fn key problem (USB Devices and other Peripherals)
- Reverse DSN problem (Domains and DNS)
- old comp wont start windows....black screen upon boot (Troubleshooting Dead Machines)
- Ufo (Geeks' Lounge)
- Recursively Reversing a String (C++)
- Reverse a String (VB.NET)
- USB for HDD? (USB Devices and other Peripherals)
Other Threads in the VB.NET Forum
- Previous Thread: Help with class
- Next Thread: Voice Recognition System
| Thread Tools | Search this Thread |
.net 3.5 6 2008 application basic beginner c# c++ calculator cms code college computers copy creat crime css database datagridview developer economy error examples folder form format ftp idc ide investors keypress label malware manufacturing mcafee microsoft mobile net news number open php predictions prime samples security spam sql stocks studio studios technology textbox timer toolbar variable vb vb.net vb6 view visual visualbasic visualbasic6 web window







