Jul 25, 2008

Variable Definition

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > VB Programming

free web hosting

Variable Definition

kvarnerexpress
I am creating a checkbook balancing program that uses multiple forms. The first form will allow the user to enter a certain number of deposits, withdrawals, etc. I want to have the ability to have the user be able to enter more than what this first screen will provide by allowing them to transfer to another form. I would like to store the data entered for each of these transaction types into a global variable (to be used throughout the project) array, and produce a total of the dollar amount of this transaction type to be used in coming up with an ending balance of the account.
My question is, is there a special way of defining these variables so that they can be referenced on all of the forms throughout the project?

Reply

everett
QUOTE(kvarnerexpress @ Mar 17 2006, 11:01 PM) *

I am creating a checkbook balancing program that uses multiple forms. The first form will allow the user to enter a certain number of deposits, withdrawals, etc. I want to have the ability to have the user be able to enter more than what this first screen will provide by allowing them to transfer to another form. I would like to store the data entered for each of these transaction types into a global variable (to be used throughout the project) array, and produce a total of the dollar amount of this transaction type to be used in coming up with an ending balance of the account.
My question is, is there a special way of defining these variables so that they can be referenced on all of the forms throughout the project?

i beleve you can use
CODE
dim yourvariable as global

or
CODE
global yourvariable

i forgot which
or just build a componint and add it to your form and then it will be part of the form and you dont have to use
global and when you want to swich unhide the one you want to show and hide the others

 

 

 


Reply

Inspiron
Hey kvarnerexpress, you will need a add a new Module into your project.

1. Click Project / Add Module
IPB Image

2. Select Module and click Open
IPB Image

3. In the new Module, create your variable as Public
IPB Image

Creating your variable as Public should now let all the forms in your project to use the same variable. You can also use this method to pass data from 1 form to another.

Also note that you cannot create a variable using "DIM" as it doesn't make sence in the module. The module is suppose to be a shared content among all the forms in the project.
CODE

Dim watever_variable_name as String

Reply

Galahad
Sorry for the late reply...

I don't know if you are using Visual Basic 6.0, or .NET, since their syntax can be different (I'm not quite sure, it's been nearly two years since I last used .NET)

Anyways, in order to make a variable global in your project (to allow all segments of your code to access it), you need to add a module to your project, or use already existing module, and add a following piece of code:
CODE

Global VarName As String


That's all there is to it, now your variable VarName is accessible throughout your code...

As Insspiron wrote, in .NET it's a little different keyword, but mostly same procedure... Use Public keyword, in place of Global...

Happy coding biggrin.gif

Reply

DeveloperX
QUOTE(Galahad @ Mar 21 2006, 11:33 AM) *

Sorry for the late reply...

I don't know if you are using Visual Basic 6.0, or .NET, since their syntax can be different (I'm not quite sure, it's been nearly two years since I last used .NET)

Anyways, in order to make a variable global in your project (to allow all segments of your code to access it), you need to add a module to your project, or use already existing module, and add a following piece of code:
CODE

Global VarName As String


That's all there is to it, now your variable VarName is accessible throughout your code...

As Insspiron wrote, in .NET it's a little different keyword, but mostly same procedure... Use Public keyword, in place of Global...

Happy coding biggrin.gif


Nice reply.
But I want to post some tick.

Well...

Such code:
CODE
Global variable1, variable2 As Integer


As You know type of variable1 is variant!!!
But variant2 is Integer.

Check your sources for this tick.

Reply

iGuest
Can you explain to me what the variable vBulletin does?
example:
$vbulletin->userinfo['buddylist'];
or $vbulletin->db->read_query("");

-nicolas

Reply

Galahad
QUOTE(FeedBacker @ Dec 4 2007, 04:59 AM) *
Can you explain to me what the variable vBulletin does?
example:
$vbulletin->userinfo['buddylist'];
or $vbulletin->db->read_query("");

-nicolas


I would say you missed a sub-forum, this is about Visual Basic, and you posted question containing PHP code...

Anyways $vbulletin, in first case, would contain information about a user, regarding buddylist, whatever that may be... Possibly a list of friends on the bulletin board...

In second case, $vbulletin would contain information read from mysql database... But, since your SQL query is empty, it would contain nothing...

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. global keyword in vb 6.0 - 8.00 hr back. (1)
  2. how to define variable in vb6 - 23.50 hr back. (1)
  3. vba define public variable - 37.77 hr back. (1)
  4. vbulletin variables - 40.87 hr back. (1)
  5. meaning and defination of hr - 41.09 hr back. (1)
  6. define basic variables - 51.57 hr back. (1)
  7. what is the meaning of $var & 1 in php - 59.31 hr back. (1)
  8. mysql variable definition - 61.25 hr back. (1)
  9. global definition in visual basic module - 62.33 hr back. (1)
  10. variable definition - 63.51 hr back. (1)
  11. code definitions visual basic #define - 87.14 hr back. (1)
  12. definition global variable vb6 - 87.98 hr back. (1)
  13. string definition in vba code - 91.20 hr back. (1)
  14. definitio of variables?types of variables? - 112.54 hr back. (2)
Similar Topics

Keywords : variable, definition

  1. Vb Variable Help
    help with variable (1)
  2. Limiting Usage Of Variable Combination
    combination of names no more than twice (1)
    Ok I have a program which prints out match lists. There are 4 games for 4 match lists will be
    printed out. The problem I have is that when I print a match list out once or twice they are all
    the same combination of names. I need a combination of names to be able to only be used twice and
    not 4 times. I.e. of how it comes out at mo Match list 1 brad VS charlie Match list 2 brad VS
    Charlie match list 3 Brad VS Charlie match list 4 brad VS charlie I.e. of how it should be
    match list 1 brad VS charlie match list 2 Brad VS helen Match list 3 Brad VS char....

    1. Looking for variable, definition

Searching Video's for variable, definition
advertisement



Variable Definition



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE