**************************************************
// Captcha Dogrulama Programı Kodlamak İçin Gerekenler
// 1 Tne PictureBox
// 1 Tane TextBoc
// 2 Tane Button [ Button 1 Dogrula - Button 2 Yenile ]
// Eger Size Yararlı Olduysa +1 Rep Vermeyi Unutmayın
**************************************************
PHP Kod:
Public Class Form1
Private Cevap As String = Nothing
Private Function KodOlustur() As String
Dim Operatorler As String() = {"+", "-"}
Baslangic:
Dim Sayi1 As Integer = New Random().Next(1, 9)
Dim Sayi2 As Integer = New Random().Next(1, 9)
If Sayi1 = Sayi2 Then GoTo Baslangic
Dim cOperatorler As String = Operatorler(New Random().Next(0, Operatorler.Length))
Select Case cOperatorler
Case "+"
Cevap = Sayi1 + Sayi2
If Cevap <= 0 Then GoTo Baslangic
Case "-"
Cevap = Sayi1 - Sayi2
If Cevap <= 0 Then GoTo Baslangic
End Select
Return String.Format("{0}{1}{2}", Sayi1, cOperatorler, Sayi2)
End Function
Private Sub CizgiOlustur(ByVal G As Graphics)
If Not G Is Nothing Then
Dim R As New Random()
Dim RenkFirca As New SolidBrush(Color.LightGray)
For i% = 0 To 9
G.DrawLines(New Pen(RenkFirca, R.Next(1, 2)), New Point() {New Point(0, R.Next(0, 60)), New Point(200, R.Next(0, 60))})
Next
End If
End Sub
Private Function ResimOlustur() As Image
Dim B As New Bitmap(200, 60)
Using G As Graphics = Graphics.FromImage(B)
With G
.Clear(Color.White)
.DrawString(KodOlustur(), New Font("Segoe UI", 20), Brushes.Black, New Rectangle(0, 0, 200, 60), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End With
CizgiOlustur(G)
End Using
Return B
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Select Case TextBox1.Text
Case Is = Cevap
MessageBox.Show("Doğru", "Doğru!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
PictureBox1.Image = ResimOlustur()
TextBox1.Clear()
Case Else
MessageBox.Show("Yanlış!", "Yanlış!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
PictureBox1.Image = ResimOlustur()
TextBox1.Clear()
End Select
TextBox1.Clear()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
PictureBox1.Image = ResimOlustur()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
PictureBox1.Image = ResimOlustur()
End Sub
End Class