Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 151
  • Last Modified:

VB 6 Pass a INT to an Function

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
Italbro1
Asked:
Italbro1
  • 2
  • 2
1 Solution
 
Arthur_WoodCommented:
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
 
hongjunCommented:
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
 
hongjunCommented:
Arthur_Wood, I did not see your posting when I typed mine.

hongjun
0
 
Arthur_WoodCommented:
no sweat...

AW
0
 
Italbro1Author Commented:
Thx you
now i know, lol
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now