[RESOLVED] Pass PictureBox to a Function to return modified PictureBox
I can't find a solution to my problem.
Trying to use a function. I want to pass a PictureBox control to this function. I want this funciton to modify the PictureBox's graphics (Lines, Boxes, Circles, etc.) and then to return the PictureBox back to the form with it's new graphics.
This is what I thought should work. Any help, or solutions?
VB Code:
Option Explicit
Function Update_Graphics(PicBox As Object) As Object 'Also have tried.. As PictureBox
PicBox.Cls 'This does not draw
PicBox.Scale (0, 0)-(50, 50)
PicBox.Line (0, 0)-(50, 50)
Set Update_Graphics = PicBox
End Function
Private Sub Command1_Click()
Dim objGraphics As PictureBox
Set objGraphics = Picture1
Set Picture1 = Update_Graphics(objGraphics)
' Picture1.Cls ' This draws fine
' Picture1.Scale (0, 0)-(50, 50)
' Picture1.Line (0, 0)-(50, 50)
End Sub
Thanks!
Re: Pass PictureBox to a Function to return modified PictureBox
This worked fine for me
VB Code:
Option Explicit
Private Sub Update_Graphics(PicBox As PictureBox) 'Also have tried.. As PictureBox
PicBox.Cls 'This does not draw
PicBox.Scale (0, 0)-(50, 50)
PicBox.Line (0, 0)-(50, 50)
End Sub
Private Sub Command1_Click()
Update_Graphics Picture1
End Sub
Re: Pass PictureBox to a Function to return modified PictureBox
I can get this to work but this is not what I want. I don't even understand what is going on in this code. I don't think the Set Update_Graphics = PicBox is working.
VB Code:
Option Explicit
Function Update_Graphics(PicBox As Object) As Object 'Also have tried.. As PictureBox
PicBox.Cls 'This draws on Picture2 , Why?
PicBox.Scale (0, 0)-(50, 50)
PicBox.Line (0, 0)-(50, 50)
Set Update_Graphics = PicBox
End Function
Private Sub Command1_Click()
' Dim objGraphics As PictureBox
' Set objGraphics = Picture1
Set Picture1 = Update_Graphics(Picture2)
' Picture1.Cls ' This draws fine
' Picture1.Scale (0, 0)-(50, 50)
' Picture1.Line (0, 0)-(50, 50)
End Sub
Re: Pass PictureBox to a Function to return modified PictureBox
Ok, I see.
Thanks a bunch!
Re: Pass PictureBox to a Function to return modified PictureBox
Try this:
VB Code:
Option Explicit
Function Update_Graphics(PicBox As PictureBox)
PicBox.Cls
PicBox.Scale (0, 0)-(50, 50)
PicBox.Line (0, 0)-(50, 50)
' Set Update_Graphics = PicBox
End Function
Private Sub Command1_Click()
Dim objGraphics As PictureBox
Set objGraphics = Picture1
Update_Graphics objGraphics
End Sub
Pradeep
UUh..
Sorry Hack, I didn't see that post!