Post: Need Little Help in VB
02-07-2011, 01:53 PM #1
wfede21
Pokemon Trainer
(adsbygoogle = window.adsbygoogle || []).push({}); ok, so i need something that writes the opposite of a word.
ex. home - emoh
hello - olleh
But there are some error :mad:, a little help? Happy

Console.WriteLine("Write something")
Dim word As String = Console.ReadLine
Dim opposite As String = ""
Dim x As Integer = Len(word)
For i As Integer = x To 1 Step -1
opposite = Mid(word, i, 1)
Next

Console.WriteLine(opposite)
Console.ReadLine()
Last edited by wfede21 ; 02-07-2011 at 01:56 PM.
02-07-2011, 03:20 PM #2
I dont know VB, but this is how i would do it in C++

    
string word;
string reversedWord;

word = "home";
int stringLength = word.length();

while(stringLength > 0)
{
reversedWord += word[stringLength -1];
stringLength --;
}

The following 2 users say thank you to TheUberFail for this useful post:

The-Don, wfede21
02-07-2011, 09:30 PM #3
The-Don
I defeated!
Try this, it's roughly how I'd do the C++ in vb.net, it should work:
Dim word As String
Dim reversedWord As String

word = "home"
Dim stringLength As Integer = word.length()

While stringLength > 0
reversedWord += word(stringLength - 1)
stringLength -= 1
End While

The following 2 users say thank you to The-Don for this useful post:

TheUberFail, wfede21
02-08-2011, 12:16 PM #4
wfede21
Pokemon Trainer
thanks! Happy

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo