Visual Basic Help!

Status
Not open for further replies.

Dan

Active Member
Messages
1,258
Reaction score
0
Points
36
Hi Everyone,
Recently I have started with Visual Basic, but I've now got a little stuck...
I need a script to save the contents of a form as a JPG file.
If anyone can do this for me or tell me how to do it easily, they will recieve around 250 credits from me.

Thanks!!! :thefinger
Dan
 

ezdookie

New Member
Messages
17
Reaction score
0
Points
0
Eh... Hi.. I don't have Visual Studio 2008 but if you are in problems you can add me to msn ezdookie@gmail.com for connect to your computer via VNC and make your job there...

Did you understand my english??.. uh..

P.D. That job was programmed with Visual Basic 6.0
 
Last edited:

Dan

Active Member
Messages
1,258
Reaction score
0
Points
36
Eh... Hi.. I don't have Visual Studio 2008 but if you are in problems you can add me to msn ezdookie@gmail.com for connect to your computer via VNC and make your job there...

Did you understand my english??.. uh..

P.D. That job was programmed with Visual Basic 6.0
I'm not sure I get what you mean...
I would just like a script please that will let me do this.
Anyone?
 

supajason

Member
Messages
288
Reaction score
2
Points
18
http://www.developerfusion.co.uk/forums/p/26911/109890/ said:
You can take and save a picture of your form like this:

Code:
Option Explicit

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Const KEYEVENTF_KEYUP = &H2

Private Function SaveFormPic() As Picture
   Dim pic As StdPicture
   Set pic = Clipboard.GetData(vbCFBitmap)
   keybd_event vbKeyMenu, 0, 0, 0
   keybd_event vbKeySnapshot, 0, 0, 0
   DoEvents
   keybd_event vbKeySnapshot, 0, KEYEVENTF_KEYUP, 0
   keybd_event vbKeyMenu, 0, KEYEVENTF_KEYUP, 0
   DoEvents
   Set SaveFormPic = Clipboard.GetData(vbCFBitmap)
   Clipboard.SetData pic, vbCFBitmap
End Function

Private Sub Command1_Click()
   SavePicture Clipboard.GetData(vbCFBitmap), "C:\MyPic.jpg" 'picture location
End Sub

The example requires one command button. It will take a picture of your form and save it into file "c:\mypic.jpg". You can change that.

Good luck.

From : http://www.developerfusion.co.uk/forums/p/26911/109890/
 

Micro

Retired staff <i> (11-12-2008)</I>
Messages
1,301
Reaction score
0
Points
36
That doesn't work either I'm afraid...
I hope I can get something that works soon.

Try this:

Put this at the top of the class file (form file, whatever)

Code:
Imports System.Drawing
Imports System.Drawing.Imaging

And this where you want to save it
Code:
Dim img as Bitmap = new Bitmap( Me.Width, Me.Height )
Dim g as Graphics = Graphics.FromImage( img )
 g.CopyFromScreen( new Point( Me.Left, Me.Top ), new Point( 0, 0 ), new Size( Me.Width, Me.Height ) )
img.Save( "filename.jpg", ImageFormat.Jpeg )
 

Dan

Active Member
Messages
1,258
Reaction score
0
Points
36
Try this:

Put this at the top of the class file (form file, whatever)

Code:
Imports System.Drawing
Imports System.Drawing.Imaging

And this where you want to save it
Code:
Dim img as Bitmap = new Bitmap( Me.Width, Me.Height )
Dim g as Graphics = Graphics.FromImage( img )
 g.CopyFromScreen( new Point( Me.Left, Me.Top ), new Point( 0, 0 ), new Size( Me.Width, Me.Height ) )
img.Save( "filename.jpg", ImageFormat.Jpeg )
That works just great micro!!! :biggrin::biggrin:
Thanks! Sending you 250 credits now for helping me.
 
Status
Not open for further replies.
Top