Imports System.Drawing
Partial Class Captcha
Inherits System.Web.UI.Page
Private Sub returnNumer()
Dim num1 As New Random
Dim num2 As New Random
Dim numQ1 As Integer
Dim numQ2 As Integer
Dim QString As String
numQ1 = num1.Next(10, 15)
numQ2 = num1.Next(17, 31)
QString = numQ1.ToString + " + " + numQ2.ToString + " = "
Session("answer") = numQ1 + numQ2
Dim bitmap As New Bitmap(85, 35)
Dim Grfx As Graphics = Graphics.FromImage(bitmap)
Dim font As New Font("Arial", 18, FontStyle.Bold, GraphicsUnit.Pixel)
Dim Rect As New Rectangle(0, 0, 100, 50)
Grfx.FillRectangle(Brushes.Brown, Rect)
Grfx.DrawRectangle(Pens.PeachPuff, Rect) ' Border
Grfx.DrawString(QString, font, Brushes.Azure, 0, 0)
Response.ContentType = "Image/jpeg"
bitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
bitmap.Dispose()
Grfx.Dispose()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call Me.returnNumer()
End Sub
End Class
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (3)
Commented:
Author
Commented:Commented: