---
title: "is there any option to save a picturebox to an textfile in vb.net"  
description: "is there any option to save a picturebox to an textfile in vb.net"  
author: "Madhu Mitha"  
published: 2015-03-20  
updated: 2026-05-15  
canonical: https://www.mindstick.com/forum/23037/is-there-any-option-to-save-a-picturebox-to-an-textfile-in-vb-dot-net  
category: ".net"  
tags: ["vb.net"]  
reading_time: 3 minutes  

---

# is there any option to save a picturebox to an textfile in vb.net

Hi thr,,\
\
i want to save my picturebox in a [text file](https://www.mindstick.com/forum/12828/converting-a-text-file-to-an-array-in-java).. is there any [option](https://www.mindstick.com/forum/159391/jquery-get-selected-option-from-dropdown) to do like tat..

## Replies

### Reply by Anonymous User

```
Public Function SetImageComment(input As Image, comment As String) As Image Using memStream As
New IO.MemoryStream()       
input.Save(memStream, Imaging.ImageFormat.Jpeg)       
memStream.Position = 0        Dim decoder As New JpegBitmapDecoder(memStream, BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.OnLoad)        Dim metadata As BitmapMetadata        If decoder.Metadata Is Nothing Then            metadata =New BitmapMetadata("jpg")        Else            metadata =decoder.Metadata        End If       
metadata.Comment = comment        Dim bitmapFrame = decoder.Frames(0)        Dim encoder As BitmapEncoder = New JpegBitmapEncoder()       
encoder.Frames.Add(bitmapFrame.Create(bitmapFrame,bitmapFrame.Thumbnail, metadata, bitmapFrame.ColorContexts))        Dim imageStream As New IO.MemoryStream       
encoder.Save(imageStream)       
imageStream.Position = 0       
input.Dispose()        input =Nothing        Return Image.FromStream(imageStream)    End UsingEnd Function
```

### Reply by Madhu Mitha

hai jennifer,,\
I developed a code to display my [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) in a picturebox using drawstring method.. i have saved that picturebox to an bmp file.. Now i have to convert that bmp file to an .txt file or byte() .. i dono how to convert it.. Can u help me in solving this problem..\
thank u in advance..**\** **my code is..**

```
Public Class Form1    Dim brush As New Drawing.SolidBrush(Color.Black)    Dim g2 As System.Drawing.Graphics    Dim img As New Bitmap(400, 100)     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged                     g2 = Graphics.FromImage(img)        PictureBox1.Image = img        g2.SmoothingMode = Drawing2D.SmoothingMode.HighQuality        g2.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit        g2.CompositingQuality = Drawing2D.CompositingQuality.HighQuality        '        g2.DrawString(TextBox1.Text, TextBox1.Font, Brushes.Red, 0, 0)          End Sub    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        SaveFileDialog1.FileName = ""        If SaveFileDialog1.ShowDialog <> 1 Then Exit Sub        Try            Select Case SaveFileDialog1.FilterIndex                Case 1                    img.Save(SaveFileDialog1.FileName, ImageFormat.Bmp)                Case 2            End Select        Catch            MsgBox("Can not save the LED image!", 48, "LED Saving")        End Try    End SubEnd Class
```

### Reply by Anonymous User

Hi Madhu, \
Could you please explain a bit more about your requirement. As per your current question we are unable to get your requirement.


---

Original Source: https://www.mindstick.com/forum/23037/is-there-any-option-to-save-a-picturebox-to-an-textfile-in-vb-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
