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 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
Hi, Instead of using BitBlt() function,you can directly print inside the picture box (using pic.print method) when you reading from the file. Also set AutoRedraw property to true.
Hi, Instead of using BitBlt() function,you can directly print inside the picture box (using pic.print method) when you reading from the file. Also set AutoRedraw property to true.
Okay, Can you tell me how am I supposed to do that? :?:
In a form
> Draw a Picture box (Picture1)
> Draw a Command Button (Command1)
Private Sub Command1_Click()
Picture1.AutoRedraw = True
Picture1.Print "Welcome"
Picture1.Print "To"
Picture1.Print "VB6"
SavePicture Picture1.Image,"C:\Test.jpg"
End Sub
Thanx!!!!!!!! That just solved my problem. But there is one last thing :)
I want to put a lot of text in the textbox which is supposed to be captured. But the textbox does not resize to the text, Although it can show scrollbars. I want it to grow as big to fit the whole text on the screen no matter how big the text is.
Is there any way it can resize itself automatically to fit the whole text?
Now, I just discovered a problem in this thing.
The PictureBox is not printing the whole block of text, but only the first line of it.
And I dont want to increase its width anymore.
What should I do then?
May be Picture1.TextHeight() and Picture1.TextWidth() help you to predict the font size
One last problem. I swear its the last one now!
Well, there is a block of text on the textbox but only the first line is being printed on the picturebox, and I dont want to increae the width of that box.
what should i do then to solve this?