2 Replies - 1572 Views - Last Post: 13 December 2009 - 08:52 AM Rate Topic: -----

#1 mihaispr  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 29-September 09

Reverse of a string input box and show message use

Posted 13 December 2009 - 03:49 AM

Hi everyone and thanks for reading my little question!

I have a windows forms application with a button on it.

When I press it it appears me a input box I type RAC and I want that it displays me in a message box (with MsgBox) the reverse of the string in this case: CAR.


Here's the code tried in my button:


In the input box I type RAC and want it to display me when I press ok button the reverse of that string CAR.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		' declaratii variabile

		Dim textOriginal As String
		Dim textFinal As String

		'StrReverse - inverseaza un sir de caractere

		textOriginal = InputBox("RAC")
		If (Len(textOriginal) = 0) Then
			textFinal = StrReverse(textOriginal)
			MsgBox("Inversul este" & textFinal)
		End If



Is This A Good Question/Topic? 0
  • +

Replies To: Reverse of a string input box and show message use

#2 mihaispr  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 29-September 09

Re: Reverse of a string input box and show message use

Posted 13 December 2009 - 04:07 AM

Solve it now!

Sorry for my post!

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		' declaratii variabile

		Dim textOriginal As String
		Dim textFinal As String

		'StrReverse - inverseaza un sir de caractere

		textOriginal = InputBox("Acesta e un input box")
		If (Len(textOriginal) <> 0) Then
			textFinal = StrReverse(textOriginal)
			'TextBox1.Text = textFinal
			MsgBox("Inversul este" & textFinal)
		End If



Was This Post Helpful? 0
  • +
  • -

#3 AmuletOfNight  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 153
  • Joined: 23-July 09

Re: Reverse of a string input box and show message use

Posted 13 December 2009 - 08:52 AM

			dim indText(len(TextOriginal))
			for x as integer = len(TextOriginal) to 1 step -1
				   indText(x) = mid(TextOriginal, x, 1)
			next
			for x as integer = 1 to len(TextOriginal)
				   textFinal = textFinal + indText(x)
			next
			MsgBox(textFinal)
	 


That should do it, sorry its not in spanish.
Also, the code may produce some small errors- make sure you dim TextOriginal and TextFinal.

This post has been edited by AmuletOfNight: 13 December 2009 - 08:54 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1