473,789 Members | 2,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(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
Sep 12 '06 #1
3 5052
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
Sep 13 '06 #2

"Randy Birch" <rg************ @mvps.orgwrote in message
news:45******** *************@n ews.astraweb.co m...
>
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
Oops, I think that last line should be
Set PickCardf = LoadPicture("J: \vb\IF\PlayingC ardImages\" + 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********@com cast.netwrote in message
news:yI******** *************** *******@comcast .com...

"Randy Birch" <rg************ @mvps.orgwrote in message
news:45******** *************@n ews.astraweb.co m...
>
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
Oops, I think that last line should be
Set PickCardf = LoadPicture("J: \vb\IF\PlayingC ardImages\" + CValue +
".gif")
Sep 13 '06 #4

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

Similar topics

5
14045
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 some characters. Can you please kindly share the code segment to workaround how to pass such a long string value to a asp page. This is how I invoke the test page:
9
1740
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 a private member of the class Account. I have a public function called getBalance(). I have another public function called deposit, which I pass the balance (by calling getBalance() using pass by reference) and a second value for the amount of...
8
5483
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
21
3315
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 sFname, int w, int h) { FileStream fs = new FileStream(sFname, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); // Read data
8
10719
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 receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
4
2473
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, as I expected. I haven't seen this behavior explained precisely in the .net world yet, so I wanted to check and make sure I've got it right. I apologize that this is a bit long. I've tried to keep it concise. There are code fragments here, but...
0
1212
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 Winform with all empty Textboxes . If user want to make changes in config file, user has to click on button to browse config file so it displays configuration file values on Form., and USer can make changes on it and save it to config file). Is there...
1
1463
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 either player enters a 'Q' and declares an overall winner. Input: Two players enter their respective plays at the prompts. Valid input is 'R', 'P', or 'S'. The program should accept bad input with an error message.'R' beats 'S'; 'S' beats 'P', and 'P'...
15
2583
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 determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the same messages because each thread gets the recors then sends the message. I need somehow to prevent...
4
8062
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 potentially dangerous Request.Form value was detected from the client (myparam="<root><blah...."). --- The fix used for ASPX pages is to include the @Page directive with
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10412
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.