|
-
Oct 6th, 2007, 12:07 PM
#1
Thread Starter
Addicted Member
variables not holding values
hello again,
im transferring a fortran program to VB, and the translator doesnt do great but it does its job. Anyway I have a huge list of public variables, these variables are set right at the beginning of the program (they are specifically set to zero). then the program calls a subroutine and then the subroutine calls another subroutine. When I check the variables some of the variables are coming in as zeros and others (that are set to zero) are coming in "empty".
Is it possible for something in the program to unset them?
Can you set the value of the public variables in the public statements?
Does setting the values in the main program possible effect the way they are transfered to different subroutines since they are public variables?
thanks guys.
-
Oct 6th, 2007, 12:58 PM
#2
Re: variables not holding values
Only variables of the type Variant can be "empty". If the variable is supposed to contain a numeric value its type should reflect that. So they should be declared as Integer or Long for integer valus and Single or Double for floating point values. By declaring the variable of the proper type it will be initilized as 0.
-
Oct 6th, 2007, 06:18 PM
#3
Re: variables not holding values
Can you set the value of the public variables in the public statements?
no you would need to to it in a proceedure such as form load
Does setting the values in the main program possible effect the way they are transfered to different subroutines since they are public variables?
once set they stay the same in all subs until they are changed or reset
this is for vb6 (vb5 /vba), the forum you have posted in
vb.net i believe you can set the variable in the declaration
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 8th, 2007, 02:20 AM
#4
Re: variables not holding values
 Originally Posted by Armageddon85
hello again,
im transferring a fortran program to VB, and the translator doesnt do great but it does its job. Anyway I have a huge list of public variables
sounds to me as if you are declaring variables in a single statement like
Dim var1, var2, var3 as Single
In Fortran they are probably all singles (I have only used Fortran back in 1979!!!), in VB6 only var3 is a single, the others are Variants!!!!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Oct 8th, 2007, 02:50 AM
#5
New Member
Re: variables not holding values
Have you declared "option explicit" at the beginning just to check you have not misspelt anything? I am no expert but sometimes its the simplest things
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|