Link to home
Start Free TrialLog in
Avatar of Neal Hartman
Neal HartmanFlag for United States of America

asked on

Save Textbox to image

How can I save the contents of a textbox to and image (jpg).
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Tomlinson
What version VB you have?

In VB.Net 2005 (or above) it is built-in:
Public Class Form1
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim bmp As New Bitmap(TextBox1.Width, TextBox1.Height)
        TextBox1.DrawToBitmap(bmp, New Rectangle(New Point(0, 0), TextBox1.Size))
        PictureBox1.Image = bmp
    End Sub
 
End Class

Open in new window

To save as a JPG (which PaulHews has already shown):
        Dim bmp As New Bitmap(TextBox1.Width, TextBox1.Height)
        TextBox1.DrawToBitmap(bmp, New Rectangle(New Point(0, 0), TextBox1.Size))
        bmp.Save("c:\someFile.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

Open in new window

Avatar of Neal Hartman

ASKER

Excellent!
So I take it you have VB.Net 2003 or below?...