PDA

View Full Version : وارونه کردن یک string



setak
دوشنبه 04 دی 1385, 11:20 صبح
آیا تابعی برای وارونه کردن یک string وجود دارد؟
برای مثال تبدیل "1234" به "4321"

Asad.Safari
دوشنبه 04 دی 1385, 15:18 عصر
ببین این کار میکنه :



StrReverse(str)

موفق باشید

zarrin_306
سه شنبه 05 دی 1385, 10:36 صبح
هدف در این کد :
تعیین طول رشته . معکوس کردن ترتیب کارکتر ها .و کپی دنبالع ای از کارکتر های درون رشته به آرایه کارکتری است




Module modMiscellaneous

Sub Main()
Dim string1, output As String
Dim characterArray As Char()
Dim i As Integer
Dim quotes As Char = ChrW(34)

string1 = "hello there"
characterArray = New Char(5) {}

' output string
output = "string1: " & quotes & string1 & quotes

' test Length property
output &= vbCrLf & "Length of string1: " & string1.Length

' loop through characters in string1 and display
' reversed
output &= vbCrLf & "The string reversed is: "

For i = string1.Length - 1 To 0 Step -1
output &= string1.Chars(i)
Next

' copy characters from string1 into characterArray
string1.CopyTo(0, characterArray, 0, 5)
output &= vbCrLf & "The character array is: "

For i = 0 To characterArray.GetUpperBound(0)
output &= characterArray(i)
Next

MessageBox.Show(output, "Demonstrating String" & _
" properties Length and Chars", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub ' Main

End Module ' modMiscellaneous