'Generate image verification code functions
Sub Validatecode (Byval Vnum As String)
DIM IMG as system.drawing.bitmap
DIM G As Graphics
DIM MS as system.io.MemoryStream
'Gheight is the width, automatically change image width according to character length
DIM GHEIGHT AS INTEGER = INT (LEN (VNUM) * 11.5)
'Creating a width of a width, a height of 20
IMG = New Bitmap (Gheight, 20)
g = graphics.fromImage (IMG)
'Draw strings in the rectangular shape (string, font, brush color, on the left X. Top left y)
g.drawstring (VNUM, NEW FONT ("Song Body", 12)), (New Solidbrush), 3, 3)
MS = new system.io.MemoryStream
IMG.SAVE (MS, System.drawing.Image.ImageFormat.png)
Response.clearContent () 'Requires Output Image Information To modify http headers
Response.contentType = "image / png"
Response.binaryWrite (ms.toarray ())
g.dispose ()
IMG.Dispose ()
Response.end ()
End Sub