?
Solved

VB 6 Pass a INT to an Function

Posted on 2003-02-28
5
Medium Priority
?
145 Views
Last Modified: 2010-05-01
Hi
I have a Dim Test in my Form_Load()

now i need to use it here :

Private Sub btnObj_Click()

how can i call it ByRef

thx
Italbro

0
Comment
Question by:Italbro1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 140 total points
ID: 8042811
if your code looks like this:

Private Sub Form_Load()
Dim Test as Integer
Test = 12
.
.
End SUb

Then you CANNOT use the value ot Test anywhere else in your program.  It is only defined within the code of that Sub.

However, if you change your code like this:

Dim Test as Integer
Private Sub Form_Load()
Test = 12
.
.
.
End SUb

now Test is declared as a FORM_LEVEL variable, and can be accessed from ANY other Sub or Function within the code of the Form.

AW
0
 
LVL 33

Expert Comment

by:hongjun
ID: 8042816
I think there's no way to do this. Try declaring Test as a form level variable

Option Explicit

Dim Test As Integer

Private Sub btnObj_Click()
    MsgBox Test
End Sub

Private Sub Form_Load()
    Test = 1
End Sub



hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 8042819
Arthur_Wood, I did not see your posting when I typed mine.

hongjun
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 8043252
no sweat...

AW
0
 

Author Comment

by:Italbro1
ID: 8044945
Thx you
now i know, lol
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question