Three examples ....
Option Explicit
Dim TheSuit As Integer, TheCardNo As Integer, MyCard As Object
Private Sub Form_Load()
Randomize
End Sub
Private Sub Command1_Click( )
Dim cp As StdPicture
'returning image as variable passed to sub
Call PickCard(TheSui t, TheCardNo, cp)
Picture1.Pictur e = cp
End Sub
Private Sub Command3_Click( )
Dim cp As StdPicture
'returning image to variable from function
Set cp = PickCardf(TheSu it, TheCardNo)
Picture1.Pictur e = cp
End Sub
Private Sub Command2_Click( )
'returning image directly to a pixbox from a function
Picture1.Pictur e = PickCardf(TheSu it, TheCardNo)
End Sub
Private Sub PickCard(ByRef CardSuit As Integer, ByRef CardNo As Integer,
CardPic As Object)
Dim CardValue As Integer
Dim CValue As String
CardSuit = Int(Rnd * 4 + 1)
CardNo = Int(Rnd * 13 + 1)
CardValue = 100 + (CardSuit - 1) * 13 + CardNo
CValue = LTrim(Str(CardV alue))
Set CardPic = LoadPicture("J: \vb\IF\PlayingC ardImages\" + CValue +
".gif")
End Sub
Private Function PickCardf(CardS uit As Integer, CardNo As Integer) As
StdPicture
Dim CardValue As Integer
Dim CValue As String
CardSuit = Int(Rnd * 4 + 1)
CardNo = Int(Rnd * 13 + 1)
CardValue = 100 + (CardSuit - 1) * 13 + CardNo
CValue = LTrim(Str(CardV alue))
Set CardPic = LoadPicture("J: \vb\IF\PlayingC ardImages\" + CValue + ".gif")
End Function
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
"Geoff" <gf****@freenet name.co.ukwrote in message
news:rO******** *************** *******@brightv iew.com...
In this code I am trying to pass an image, as a parameter, out of the
procedure PickCard. The code will not support this. How do I pass an image
as a parameter?
Thanks again
Geoff
Dim TheSuit As Integer, TheCardNo As Integer, MyCard As Object
Private Sub PickCard(ByRef CardSuit As Integer, ByRef CardNo As Integer,
ByRef CardPic As Object)
Dim CardValue As Integer
Dim CValue As String
Randomize
CardSuit = Int(Rnd * 4 + 1)
CardNo = Int(Rnd * 13 + 1)
CardValue = 100 + (CardSuit - 1) * 13 + CardNo
CValue = LTrim(Str(CardV alue))
CardPic.Picture = LoadPicture("J: \vb\IF\PlayingC ardImages\" + CValue +
".gif")
End Sub
Private Sub ButDeal_Click()
Call PickCard(TheSui t, TheCardNo, MyCard)
End Sub