Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
Help with parameter p***ing please
Old
  (#1)
Geoff
Guest
 
Posts: n/a
Default Help with parameter p***ing please - 06-04-2007, 10:31 AM

In this code I am trying to p*** an image, as a parameter, out of the
procedure PickCard. The code will not support this. How do I p*** 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(CardValue))

CardPic.Picture = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue +
".gif")



End Sub





Private Sub ButDeal_Click()



Call PickCard(TheSuit, TheCardNo, MyCard)



End Sub


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: Help with parameter p***ing please
Old
  (#2)
Randy Birch
Guest
 
Posts: n/a
Default Re: Help with parameter p***ing please - 06-04-2007, 10:31 AM

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 p***ed to sub
Call PickCard(TheSuit, TheCardNo, cp)
Picture1.Picture = cp

End Sub

Private Sub Command3_Click()

Dim cp As StdPicture

'returning image to variable from function
Set cp = PickCardf(TheSuit, TheCardNo)
Picture1.Picture = cp

End Sub

Private Sub Command2_Click()

'returning image directly to a pixbox from a function
Picture1.Picture = PickCardf(TheSuit, 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(CardValue))

Set CardPic = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue +
".gif")

End Sub

Private Function PickCardf(CardSuit 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(CardValue))

Set CardPic = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue + ".gif")

End Function

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Please reply to the newsgroups so all can participate.




"Geoff" <EMAIL REMOVED> wrote in message
news:rO-EMAIL REMOVED...
In this code I am trying to p*** an image, as a parameter, out of the
procedure PickCard. The code will not support this. How do I p*** 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(CardValue))

CardPic.Picture = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue +
".gif")



End Sub





Private Sub ButDeal_Click()



Call PickCard(TheSuit, TheCardNo, MyCard)



End Sub


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Help with parameter p***ing please
Old
  (#3)
Steve Gerrard
Guest
 
Posts: n/a
Default Re: Help with parameter p***ing please - 06-04-2007, 10:31 AM


"Randy Birch" <EMAIL REMOVED> wrote in message
news:450753d2$0$9389$EMAIL REMOVED...
>
> Private Function PickCardf(CardSuit 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(CardValue))
>
> Set CardPic = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue + ".gif")
>
> End Function
>


Oops, I think that last line should be
Set PickCardf = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue + ".gif")


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: Help with parameter p***ing please
Old
  (#4)
Randy Birch
Guest
 
Posts: n/a
Default Re: Help with parameter p***ing please - 06-04-2007, 10:31 AM

Right -- oops. In my test app I had used hard-coded paths on a line below
the OPs line and didn't update the name of the function as used in the test
call. Thanks.

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Please reply to the newsgroups so all can participate.




"Steve Gerrard" <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED. ..

"Randy Birch" <EMAIL REMOVED> wrote in message
news:450753d2$0$9389$EMAIL REMOVED...
>
> Private Function PickCardf(CardSuit 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(CardValue))
>
> Set CardPic = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue +
> ".gif")
>
> End Function
>


Oops, I think that last line should be
Set PickCardf = LoadPicture("J:\vb\IF\PlayingCardImages\" + CValue +
".gif")


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top