Hi all,
Here's what I wanna code in VB 2005:
I have a textbox that accepts only numeric characters upto 17 characters max. now, depending on the button i click, i want to either rearrange those characters and/or strip them (based on the character postion) to have another combination.
Example:
I input 27130948129045716 on the text box. i click on a button to convert it into 12 characters (by taking the last 5 digits, strip the 2nd to 6th digits, take the first digit, 7th to 11th digit; we can place these digits into separate variables so it will be easier rearranging them) and i will get as final result: 457162481290.
Any input will be greatly appreciated.
Thanks and more power

How to strip/Rearrange textbox characters?
Gabeh
str1 = Strings.Left(str2, 5) <-- the 5 left-hand characters of the string
str2 = Strings.Right(str2, 5) <-- the 5 RIGHT-hand characters of the string
There's also the MID statement that has a syntax of:
MID(STRING, START CHARACTER, LENGTH [Optional})
So if I wanted to get the "ell" out of "hello", the code would be:
MID("hello", 2, 3)
the length is optional, but if you leave it out, it returns from the start character to the end of the string. For example:
MID("hello", 2)
would return "ello"
Hope this sets you on the right track!! :-)
bertuahki
Hey yah guys, Thanks much for the insight, it's been a while since I last coded in Visual Basic/.Net. Both replies (the Mid and substring solutions work and I just wonder why i have been searching for so long in my latest 3gb MSDN library. i gues i was asking the wrong questions and you guys rock!!!
Thanks, Cyto
asifbhura
Slightly off-topic, but what is the difference between "Microsoft.Visualbasic.Left(..." and "Microsoft.Visualbasic.Strings.Left(..." functions Or are they the same function just entered from different points
And if different which is the "best practice" to use
Bradonline
How about the following using substring method. Which has two parameters, start position and length. Remembering that it is 0 based so the first item is at position 0.
Left$, Right$ and Mid$ can also be used as previously stated.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = 27130948129045716
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = RearrangeText(TextBox1.Text)
End Sub
Function RearrangeText(ByVal text1 As String) As String
Dim s As String
If text1.Length = 17 Then
s = text1.Substring(text1.Length - 5, 5)
s = s & text1.Substring(0, 1)
s = s & text1.Substring(6, 6)
End If
Return s
End Function
End Class