I have written a program that reads a text file and then saves it as an image file.Although the program is reading the file but its having errors saving it as an image file. Please Help!
Option Explicit Private Const SRCCOPY = &HCC0020 Private Const MERGEPAINT = &HBB0226 Private Const SRCAND = &H8800C6 Private Const DIB_RGB_COLORS = 0 Private Const DIB_PAL_COLORS = 1 Private Declare Function BitBlt Lib "gdi32" _ (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _ ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, _ ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Dim nRet As Long Private Sub Command1_Click() 'Outline:- Asks the user for a file. '- Reads all the data into Text1. Dim FilePath As String Dim Data As String FilePath = InputBox("Enter the path for a text file", "The Two R's", _ "D:\address.txt") 'Asks the user for some input via an inp ' ut box. Open FilePath For Input As #1 'Opens the file given by the user. Do Until EOF(1) 'Does this loop until ' f>End Of File(' >EOF) for file number 1. Line Input #1, Data 'Read one line and puts it into the vari ' ble Data. Text1.Text = Text1.Text & vbCrLf & Data 'Adds the read line into Text1. MsgBox EOF(1) Loop Close #1 'Closes this file. End Sub Private Sub Command2_Click() pic.Visible = True pic.Height = Text1.Height pic.Width = Text1.Width nRet = BitBlt(pic.hDC, 0, 0, Text1.Width - 2, Text1.Height - 2, Me.hDC, Text1.Left + 1, Text1.Top + 1, SRCCOPY) pic.Picture = pic.Image SavePicture pic.Image, "text.bmp" pic.Visible = False Text1.SetFocus End Sub