A Visual Basic 6 problem,

Status
Not open for further replies.

undark

Ars Scholae Palatinae
638
If you're inputting a number through a textbox, you might consider doing this:
Code:
myVar = Val(txtFoo.Text)
That will input the text as a number, instead of a string. At least I think so, my VB teacher is incompetent. Maybe you could try this?
Code:
Val(myStringVar) As Double

I'm not really sure what you're asking, though, and my answer may be way off base. Could you clarify your situation?
 

Alphafury

Ars Scholae Palatinae
1,366
I was kinda sleepy.
Here is my exact question. I want to make a frame pop up when there's an error in my program. I got that far. Now I need to put a string from the work frame to the error popup form.

Basicly how do I declare a string for the entire program, I want the string to be editable so I only have to use one form for error messages.

Hope this makes it more clear.
 

enkafan

Wise, Aged Ars Veteran
111
no clue what you mean by frame (probably form).

If you have a variable you want other forms to be able to interact with, you need to change its scope. Basically scope is how famous it is. When you use DIM inside a procedure (sub or function), you get a variable with a local scope. Only code within that same procedure knows about it.

To make it more 'famous,' but the declaration into the general declarations section of the form (general declarations is the very top before the first procedure).

The code should look like this:
Public myVar as String

Then you can work with myVar like any other variable while in that form. Now, if you want to access that variable from another form you need to use this syntax (assuming myVar is declared in a form called frmMain):

frmMain.myVar = "test"

Now, if you want to create a variable the WHOLE program can see (a global variable if you will), use the same public declaration in a standard module in its general declaration. Now everyone knows about that variable.
 
Status
Not open for further replies.