Please help me debug. This script generate the wrong barcode. please help me verify the problem. thanks!

**********************************************************
Dim Input As String = Request.Querystring("input")
If Input = "" Then Input = "drdigit.com"
Dim ValidInput As String = " !" & Chr(34) & "#$%&()**+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~" & Chr(0) & Chr(1) & Chr(2) & Chr(3) & Chr(4) & Chr(5) & Chr(6) & Chr(7) & Chr(8) & Chr(9) & Chr(10) & Chr(255)
Dim ValidCodes As String = "174016441638117611641100122412201124160816041572143612441230148412601254165016281614176416521902186 8183618301892184418421752173415901304111210941416112811221672157615701464142211341496147811421910167 8158217681762177418801862181418961890181819141602193013281292120011581068106214241412123212181076107 4155416161978155611461340121211821508126812661956194019381758178219741400131011181512150619601954150 21518188619661724168016926379"
Dim Digit As Integer = 104
Dim i As Integer
For i = 1 to Input.Length
Digit += (i * Instr(1, ValidInput, Mid(Input, i, 1)))
Next
Digit = Digit Mod 103
Input = Chr(9) & Input & Mid(ValidInput, Digit, 1) & Chr(255)
Dim bmp As Bitmap = New Bitmap((Input.Length * 11) + 13, 50)
Dim g As Graphics = Graphics.FromImage(bmp)
g.FillRectangle(New SolidBrush(Color.White), 0, 0, (Input.Length * 11) + 13, 50)
Dim p As New Pen(Color.Black, 1)
Dim BarValue, BarX As Integer
Dim BarSlice As Short
For i = 1 To Input.Length
Try
BarValue = Val(Mid(ValidCodes, ((InStr(1, ValidInput, Mid(Input, i, 1)) - 1) * 4) + 1, 4))
If BarValue > 0 Then
Digit = 11
If i = Input.Length Then Digit = 13
For BarSlice = Digit To 0 Step -1
If BarValue >= 2 ^ BarSlice Then
g.DrawLine(p, BarX, 0, BarX, 50)
BarValue = BarValue - (2 ^ BarSlice)
End If
BarX += 1
Next
End If
Catch
End Try
Next
bmp.Save(Response.OutputStream, ImageFormat.GIF)
g.Dispose()
bmp.Dispose()