Hanya sharing pengalaman: nge blog, google AdSense, cyber enjoyable

Naruto Fans Kampanye Damai Pemilu Indonesia 2009 Mendukung SBY untuk menjadi Presiden 2009-2014

Jul 6, 2007

Reversing the Order of Characters in Strings

Visual Basic's new StrReverse() function enables you to completely reverse the order of a string. Its syntax is as follows:

strResult = StrReverse(strMyString)

In this syntax,

  • Text2 is the string returned from the function.
  • Text1 is the function name.

Visual Basic defaults all internal variables to valid values--numeric variables default to zero, and strings default to empty. The problem happens when you take a null data field from a database and assign it to an internal variable or when you perform a string function on the null data field.

In this version, a loop was required to step through each character in the string and then build the new string in reverse order. The code in Listing below delivers the same result with the new "StrReverse()" function, with no loops and only one simple command.

Code example:

Private Sub Form_Load()

Text1.Text = "Pitik Jago Kluruk 34X"

Text2.Text = ""

End Sub

Private Sub Command1_Click()

Text2.Text = StrReverse(Text1.Text)

End Sub


0 comments:

Alexa Rank