I need a function (or code) that will physically change the words in a text
string to make the first word be last, second word next to last, etc. but
maintain the same position of the letters in each word.
e.g.
Before: The dog ran
After: ran dog the
Is there such a thing?
Thanks!
Bob 5 3761
On Oct 2, 11:07 am, BobAchgill <BobAchg...@discussions.microsoft.com>
wrote:
I need a function (or code) that will physically change the words in a text
string to make the first word be last, second word next to last, etc. but
maintain the same position of the letters in each word.
e.g.
Before: The dog ran
After: ran dog the
Is there such a thing?
Thanks!
Bob
How about this:
/////////////////
Module Module1
Sub Main()
Dim text As String = "The dog ran after the car"
Dim words As String() = text.Split(" "c)
Dim newText As String = String.Empty
For i As Integer = words.Length - 1 To 0 Step -1
newText &= words(i) & " "
Next
Console.WriteLine(newText)
Console.Read()
End Sub
End Module
////////////////////
Thanks,
Seth Rowe
"BobAchgill" <Bo********@discussions.microsoft.comschrieb
I need a function (or code) that will physically change the words in
a text string to make the first word be last, second word next to
last, etc. but maintain the same position of the letters in each
word.
e.g.
Before: The dog ran
After: ran dog the
Is there such a thing?
Dim s As String = "The dog ran"
Dim words As String() = s.Split(" "c)
Array.Reverse(words)
s = String.Join(" "c, words)
Armin
BobAchgill wrote:
I need a function (or code) that will physically change the words in a text
string to make the first word be last, second word next to last, etc. but
maintain the same position of the letters in each word.
e.g.
Before: The dog ran
After: ran dog the
Is there such a thing?
Thanks!
Bob
I would almost assume you would have to read the file char by char, and
add to an "arraylist" every time you hit a space.
Then in the end, fly thru the array list backwards and write it back.
Im a newbie though.
M.
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@g4g2000hsf.googlegrou ps.com...
On Oct 2, 11:07 am, BobAchgill <BobAchg...@discussions.microsoft.com>
wrote:
>I need a function (or code) that will physically change the words in a text string to make the first word be last, second word next to last, etc. but maintain the same position of the letters in each word.
e.g. Before: The dog ran After: ran dog the
Is there such a thing?
Thanks!
Bob
How about this:
/////////////////
Module Module1
Sub Main()
Dim text As String = "The dog ran after the car"
Dim words As String() = text.Split(" "c)
Dim newText As String = String.Empty
For i As Integer = words.Length - 1 To 0 Step -1
newText &= words(i) & " "
Next
Console.WriteLine(newText)
Console.Read()
End Sub
End Module
////////////////////
Thanks,
Seth Rowe
I was going along this route too, trying to help out, then remembered that
you can use an Array and use the Reverse method :D
Mythran
On Oct 2, 11:51 am, "Mythran" <kip_pot...@hotmail.comwrote:
"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message
news:11*********************@g4g2000hsf.googlegrou ps.com...
On Oct 2, 11:07 am, BobAchgill <BobAchg...@discussions.microsoft.com>
wrote:
I need a function (or code) that will physically change the words in a
text
string to make the first word be last, second word next to last, etc. but
maintain the same position of the letters in each word.
e.g.
Before: The dog ran
After: ran dog the
Is there such a thing?
Thanks!
Bob
How about this:
/////////////////
Module Module1
Sub Main()
Dim text As String = "The dog ran after the car"
Dim words As String() = text.Split(" "c)
Dim newText As String = String.Empty
For i As Integer = words.Length - 1 To 0 Step -1
newText &= words(i) & " "
Next
Console.WriteLine(newText)
Console.Read()
End Sub
End Module
////////////////////
Thanks,
Seth Rowe
I was going along this route too, trying to help out, then remembered that
you can use an Array and use the Reverse method :D
Mythran
Yeah, curse me and my obsessive need to do everything the manual
way. :-)
Besides, this is the first time in about a year I had a need to use
the "Step" keyword :-)
Thanks,
Seth Rowe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Simon |
last post by:
Hi,
I have written a function to trim char *, but I have been told that my way
could be dangerous and that I should use memmove(...) instead.
but I am not sure why my code could be 'dangerous'...
|
by: rkleiner |
last post by:
Is there a regular expression to find the first unmatched right bracket
in a string, if there is one? For example,
"(1*(2+3))))".search(/regexp/) == 9
Thanks in advance.
|
by: Agnes |
last post by:
in .net , any left function ??
or I should use Microsoft.VisualBasic.Left(myString, 5)
Thanks
|
by: ReidarT |
last post by:
How do I use left, mid and right in vb.net?
regards
reidarT
|
by: patang |
last post by:
This is really silly question.
Dim s As String
s = "the"
s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to
do to make it work in VB.Net)
I have...
| |
by: sql guy123 |
last post by:
I normally use MS ACCESS vs MS SQL,, which has a left() and right()
function. I need to use MS SQL for this project but I am not familiar
with it. I have read a few books, but can not figure out...
|
by: muler |
last post by:
Hi all,
This is an excerpt from the Book "Programming Microsoft Visual C#: The
Language":
A function evaluates to the return value. When a reference type is
returned, a function is available...
|
by: =?Utf-8?B?R3JlZw==?= |
last post by:
I have two questions with regards to the LEFT function.
I ran into a problem with the LEFT function today. I knew it was a valid
Function, but when I tried to use it, it was getting interpreted...
|
by: Steve |
last post by:
I use the instr function frequently to find particular characters
within a string and manipulate them eg all characters to the left of a
particular character.
If I understand correctly, Instr...
|
by: marc |
last post by:
Hello,
Is it possible to right pad with "0" (or other character != blank) ?
for example :
1 , length 10 ="1000000000"
I've tried with sprintf but I can only left pad with "0" or right pad
with...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |