473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help with parameter passing please

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(CardValue))

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

End Sub

Private Sub ButDeal_Click()

Call PickCard(TheSuit, TheCardNo, MyCard)

End Sub
Sep 12 '06 #1
3 5033
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(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" <gf****@freenetname.co.ukwrote in message
news:rO******************************@brightview.c om...
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(CardValue))

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

End Sub

Private Sub ButDeal_Click()

Call PickCard(TheSuit, TheCardNo, MyCard)

End Sub
Sep 13 '06 #2

"Randy Birch" <rg************@mvps.orgwrote in message
news:45*********************@news.astraweb.com...
>
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")
Sep 13 '06 #3
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" <my********@comcast.netwrote in message
news:yI******************************@comcast.com. ..

"Randy Birch" <rg************@mvps.orgwrote in message
news:45*********************@news.astraweb.com...
>
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")
Sep 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Belinda | last post by:
Hello All I have the following test.asp page which needs one parameter querystr but my querystr is a very long string value. When I send a long value the query string is getting truncated after...
9
by: SB | last post by:
Ok, very simple problem. I'm trying to update a value by calling a function using pass by reference, but it does not update the value. In short, the value I'm trying to update is balance, which is...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
21
by: vmsgman | last post by:
Here is a code sample ... int blah = ReadFile( defArray, defFileName, w, h); // Read File Contents into memory array and return for processing public int ReadFile( ref ushort nArray, string...
8
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to...
4
by: Warren Sirota | last post by:
Hi, Please let me know if I am interpreting this correctly. I've done a little testing of the difference between passing parameters byVal and byRef, and the results were slightly non-intuitive,...
0
by: ohmp05 | last post by:
Hi all, I am new to deployment of application. If any one please help me on it , that will be great. During the installation of project, Installer will execute an utility( It will display...
1
by: phuker420 | last post by:
don't know how to get started please help with this program. rock,paper,scissors We will write a program that multiple games of rock, paper, scissors: keeps a cumulitive score, quits when...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
4
by: =?Utf-8?B?QmlsbEF0V29yaw==?= | last post by:
Hi, We recently converted a 1.1 project to 2.0 and this included a webservice which accepted XML for one of the parameters. Since converting to 2.0 I am getting the following message: --- A...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.