Loop through the text box right to left, character by character.
Delclare yourself a long or double variable.
When you find a "1" in the text box, set the bit in the long variable that corresponds to the current position in the text box.
eg:
Text in text box is "10110"
Code:
Select Case lPos 'lPos is the current position, 1 being rightmost
Case 1
varLong = varLong Or 1
Case 2
varLong = varLong Or 2
Case 3
varLong = varLong Or 4
Case 4
varLong = varLong Or 8
Case 5
varLong = varLong Or 16
Case n
varLong = varLong Or (n^2)
End Select
txtDecimal.Text = Cstr(varLong)
I've used a case to illustrate the technique, bu that is a bad way of doing it (cos you have no idea how long the binary string is. A better option is
lChar = The char to dela with
lPos = the curent position in the string
Code:
If lChar = "1" then
varLong = varLong Or (lPos^2)
End If
That should work nicely (although I admit that I wrote that without testing it in VB)
- gaffa