02-05-17, 01:42 AM
السلام عليكم
طلبي حل مشكلة هذا الكود لماذا يوجد هذا الخطأ
كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = SMCaptcha(chkCapsOnly.Checked)
TextBox1.Text = PictureBox1.Image.Tag
End Sub
Private Function SMCaptcha(ByVal CapsOnly As Boolean) As Bitmap
Dim Img As New Bitmap(260, 90)
Dim G As Graphics
Dim U As System.Drawing.GraphicsUnit = GraphicsUnit.Pixel
Dim S As System.Drawing.FontStyle = FontStyle.Bold + FontStyle.Italic
Dim Sz As Single = 40
Dim Br As New TextureBrush(My.Resources.Brush)
Dim strText As String = ""
Dim X, Y As Integer
Dim C As String
Dim Chars As String = "a1bcd23ef89ghi36jk5l6m7n2o4p0q1r8s9t2uvwx4y8z"
If CapsOnly Then
Chars = UCase(Chars)
End If
While Len(strText) <> 5
G = Graphics.FromImage(Img)
G.PixelOffsetMode = Drawing2D.PixelOffsetMode.Half
G.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
G.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
G.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasGridFit
Dim p As Int16
For i = 1 To 5
Randomize(Now.Millisecond)
Y = Rnd(Now.Millisecond) * 25 + 1
C = "*"
Sz = Rnd(Now.Millisecond) * 5 + 30
X = X + 20 + Rnd(Now.Millisecond) * 15
If Y + Sz > Img.Height - 10 Then
Y = Img.Height - Sz
End If
While InStr(Chars, C) = 0
p = (Rnd(Now.Millisecond) * (Len(Chars) - 1)) + 1
C = Mid(Chars, p, 1)
End While
strText += C
Dim strFont As String = "Consolas"
G.DrawString(C, New System.Drawing.Font(strFont, Sz, U, S), Br, X, Y)
G.DrawString(C, New System.Drawing.Font(strFont, Sz, U, S), Br, X, Y + 1)
G.DrawString(C, New System.Drawing.Font(strFont, Sz, U, S), Br, X + 1, Y + 2)
G.DrawString(C, New System.Drawing.Font(strFont, Sz, U, S), Br, X + 1, Y + 1)
Next
End While
Img.Tag = strText
Return Img
End Function
End Class
وشكرا مقدما