02-23-2008, 10:11 AM
what's the difference between form.show and load form?
- does setting focus to a form mean have it selected?
- can you load a form twice?
- so whats better, load / unload or show / hide?
02-23-2008, 12:45 PM
Load form simply loads the form. Form.show will load the form, make the form visible and set focus to it.
Usually setting any properties on a form or the controls on it will cause the form to be loaded, form.show included.
02-23-2008, 01:12 PM
Similar to the difference between form.Hide and Unload form for that matter.
02-23-2008, 01:16 PM
ok new problem..
I'm making subroutines for each stage of my program. But when the same variables are called from a sub, their value is "Empty", which would mean the value didn't carry over when I called the subroutine. I'm not even sure if I'm doing it right. I'm going to Tools, adding a new procedure > sub. Scope> public.
So it looks like:
Public Sub Action
CC(1, iTable) = GetPixel(Hdc, X - 80, Y - 175)
If (iTable = 1) Then RedTable1.Show
and the CC(1, iTable) = Empty when it should = a real value if everything was run under one Sub.
- I just DIM'd it in General so it should work now
- But What if it's between forms under the same project? Can you still carry the variable values over?
02-23-2008, 01:39 PM
Simply dimming something is the same as making it private
dim x as integer
private x as integer
The only way to make it accessible from other forms or modules is to specificly make it public
public x as integer
If you declare a variable in a sub then it is only available within that sub. It will not be available to any others even if you call them from within your sub
private sub test()
dim x as integer
private sub anothersub()
'x doesnt exist in here
02-23-2008, 02:18 PM
thanks for the tip.... but i still can't get it to work
in my main form i have:
xxx(1) = #
yyy(1) = #
xxx(2) = #
yyy(2) = #... and so on
x = xxx(iTable)
y = yyy(iTable)
In the form I want to call using RedTable.show I have:
Private Sub Form_Load()
SetWindowPos Me.hWnd, HWND_TOPMOST, x - 370, y - 457, 633, 305, SWP_NOACTIVATE Or SWP_SHOWWINDOW
Transparency Me.hWnd, 0
When I stop the program at End Sub***, it says my x and y values are Empty even tho I declared x and y public in my form1 general. However, I can't declare my array's public, I can only say Dim xxx(8), yyy(8)?
So I think what it's doing is its trying to read xxx(itable) since that's what x equals, and that can't be public. Am I making sense?
ps. my itable and xxx are clearly defined by this point so they can't be empty. I'm gonna test it again to see what x is in form1
yeah my x and y values are shown in my form1 but are empty in form2
They're both public'd as integer in form1 general
What am i doing wrong?
02-23-2008, 02:29 PM
Arrays cannot be declared as public members of object modules. That means you cant declare them in a form. You can declare them in a module though and tell your form to load the values from there.
If x is declared publicly but you give it a value from a privately declared variable then that does *not* affect it. It should function as normal.
Try putting a break point over "x = xxx(iTable)". Check that iTabel contains the correct number and check that the item in the xxx array you are referencing contains a valid number. If they do then add a breakpoint to the following line and press F5. x should now contain the value you want.
If you still have trouble you can upload your project so we can take a look
02-23-2008, 02:57 PM
Make sure you have Option Explicit heading each module too.
02-23-2008, 03:48 PM
yeah all i needed was to put it in your module master..
and then i used global, but im sure public works too.
Before I had it in form1 as a "brother" form of form2
02-23-2008, 10:18 PM
Making them public in a module makes them visible to all forms and modules directly.
If you make them public in a form, then you have to qualify them in other forms to have visibility to them.
i.e. xxx declared public in form1, can be reference in form2 as Form1.xxx
02-23-2008, 11:30 PM
gotcha.. thanks guys!
ok new question:
what is the command for recognizing a right click? I want to say if x,y screen coordinates are within a certain parameter, then something will happen.
somethin like this?
Private Sub Object_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then