说简单点就是生成验证码的方法。 Private Sub Paint(ByVal strCode As String) Dim strImgPath As String = Server.MapPath("myCodeImg.jpg") Dim strTempPath As String = strImgPath System.IO.File.Delete(strImgPath)
Const intWidth As Int16 = 400 Const intHeight As Int16 = 150
Dim myBimap As System.Drawing.Image = New System.Drawing.Bitmap(intWidth, intHeight)
Dim myG As System.Drawing.Graphics = System.Drawing.Graphics.fromImage(myBimap)
Dim myFont As System.Drawing.Font = New System.Drawing.Font("幼圆", 16, FontStyle.Bold)
Dim myRect As System.Drawing.RectangleF = New System.Drawing.RectangleF(2, 2, intWidth, intHeight)
Dim myBrush As System.Drawing.SolidBrush = New System.Drawing.SolidBrush(Color.White)
myG.Clear(Color.Blue)
myG.DrawString(strCode, myFont, myBrush, myRect)
myBimap.Save(strTempPath, System.Drawing.Imaging.ImageFormat.Jpeg) Image1.ImageUrl = strTempPath myG.Dispose() myBimap.Dispose() End Sub