nc = Len(Text1) y = 0 w = 0 For x = 1 To nc u = Mid(Text1, nc - w, 1) v = Val(u) z = v * (2 ^ (y)) y = y + 1 w = w + 1 result = result + z Next x Text1 = result End If
If trans = 2 Then 'octal a decimal nc = Len(Text1) y = 0 w = 0 For x = 1 To nc u = Mid(Text1, nc - w, 1) v = Val(u) z = v * (8 ^ (y)) y = y + 1 w = w + 1 result = Val(result + z) Next x Text1 = result End If
If trans = 3 Then 'hexadecimal a decimal nc = Len(Text1) y = 0 w = 0 For x = 1 To nc u = Mid(Text1, nc - w, 1) If u = "A" Then v = 10 End If If u = "B" Then v = 11 End If If u = "C" Then v = 12 End If
If u = "D" Then v = 13 End If
If u = "E" Then v = 14 End If
If u = "F" Then v = 15 End If If u <> "A" And u <> "B" And u <> "C" And u <> "D" And u <> "E" And u <> "F" Then v = Val(u) End If
z = v * (16 ^ (y)) y = y + 1 w = w + 1 result = result + z Next x Text1 = result Else Text1 = Text1 End If trans = 0
End Sub
Private Sub Option2_gotfocus() Binario If trans = 1 Or trans = 2 Or trans = 3 Then Call Option1_gotfocus End If
x = Val(Text1) z = 1 While (z <> 0) y = Int(x / 2) w = x Mod 2 cadena = w & cadena 'str(valor a convertir) x = y If y = 0 Then z = 0 End If Wend Text1 = cadena trans = 1 End Sub
Private Sub Option3_gotfocus() Octal If trans = 1 Or trans = 2 Or trans = 3 Then Call Option1_gotfocus End If
x = Val(Text1) z = 1 While (z <> 0) y = Int(x / 8) w = x Mod 8 cadena = w & cadena 'str(valor a convertir) x = y If y = 0 Then z = 0 End If Wend Text1 = cadena trans = 2 End Sub
Private Sub Option4_gotfocus() Hexadecimal If trans = 1 Or trans = 2 Or trans = 3 Then Call Option1_gotfocus End If x = Val(Text1) z = 1 While (z <> 0) y = Int(x / 16) w = x Mod 16 If w = 10 Then cadena = "A" End If If w = 11 Then cadena = "B" End If If w = 12 Then cadena = "C" End If If w = 13 Then cadena = "D" End If If w = 14 Then cadena = "E" End If If w = 15 Then cadena = "F" End If If w <> 10 And w <> 11 And w <> 12 And w <> 13 And w <> 14 And w <> 15 Then cadena = w End If If w = 0 Then cadena = suma End If suma = cadena & suma cadena = 0 x = y
If y = 0 Then z = 0 End If Wend Text1 = suma trans = 3 End Sub