, , .
value/targetBase .
Fix(), , .
, .
, , IntToString.
:
:
0 1 10 101 100 101 1010 1001 1000 1001 1010
0 1 1X 10 11 1XX 1X0 1X1 10X 100 101
0 1 X 1y 10 11 XX Xy X0 X1 XX
0 1 X 1y 1z 10 11 1X Xy Xz X0
:
0 1 10 11 100 101 110 111 1000 1001 1010
0 1 X 10 11 1X X0 X1 XX 100 101
0 1 X y 10 11 1X 1y X0 X1 XX
0 1 X y z 10 11 1X 1y 1z X0
.
Public Sub test()
Dim numberCharacters As String = "01Xyz"
Dim messageText As String = "The old results are;" & vbNewLine
For loopCount As Integer = 1 To 2
If loopCount = 2 Then messageText &= "The new results are;" & vbNewLine
For baseLength As Integer = 2 To 5
Dim baseCharacters As Char() = _
Strings.Left(numberCharacters, baseLength).ToArray
For integerValue As Integer = 0 To 10
Dim resultText As String = _
Me.IntToString(integerValue, baseCharacters, loopCount = 2)
messageText &= resultText & " "
Next
messageText &= vbNewLine
Next
Next
Call MsgBox(berichtTekst & "The new results are better IMHO.")
End Sub
Public Function IntToString(value As Integer, baseChars As Char(), _
Optional newCode As Boolean = False) As String
Dim result As String = String.Empty
Dim targetBase As Integer = baseChars.Length
Do
result = baseChars(value Mod targetBase) & result
If newCode Then ' Improved code
value = Fix(value / targetBase)
Else ' Original code
value = value / targetBase
End If
Loop While value > 0
Return result
End Function
, .
I have over 25 years of experience as a programmer, mainly in RPG, Cobol, Synon, CL, and Basic. I also know some Delphi, Pascal and C #. I am sure I can help this community.
I am sad that I can not comment on the answers. I hope someone will add a few points to me so that I can now help others more easily.
Because of this, I add my comment to Tilak's answer, dated May 8, 2012, as an answer. This is the first and, I hope, the only time I resort to this. Sorry for that, but I don't know another way.
Evert source
share