Please help with code...what is wrong????

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello everyone, i have a form that includes 3 buttons 1 listbox:
This application does this(On load):For every folder in a pre-specified location, it creates a new form with its name and a list of the files/folders in it.These forms are thin (380, 20) so i have made some code that stacks them at the side of the screen.The
first button stacks them on the right, the sencond on the left, and the third let them move free(when stacked they cannot be moved).A setting named "Stack" gives the info about the stackstyle.Here is the code(the one relative to the problem):

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim setting <span style="color:Blue; as <span style="color:Blue; New <span style="color:Blue; My.mysettings
LOAD
<span style="color:Blue; Dim s <span style="color:Blue; As <span style="color:Blue; Integer = 0
<span style="color:Green; code....
<span style="color:Blue; for <span style="color:Blue; each item <span style="color:Blue; as <span style="color:Blue; string <span style="color:Blue; in listbox1.items
<span style="color:Blue; dim NF <span style="color:Blue; as <span style="color:Blue; new MYFORM
<span style="color:Green; code....
<span style="color:Blue; If setting.Stack = <span style="color:#A31515; "Free" <span style="color:Blue; Then
NF.Location = <span style="color:Blue; New Point(locX, locY) <span style="color:Green; locx,y are dims inside the code,dont mind them
<span style="color:Blue; ElseIf setting.Stack = <span style="color:#A31515; "Right" <span style="color:Blue; Then
NF.Location = <span style="color:Blue; New Point(900, s)
s += 20
<span style="color:Blue; ElseIf setting.Stack = <span style="color:#A31515; "Left" <span style="color:Blue; Then
NF.Location = <span style="color:Blue; New Point(0, s)
s += 20
<span style="color:Blue; End <span style="color:Blue; If
<span style="color:Green; code....
<span style="color:Blue; Stop load
[/code]
Now, becouse i cannot refer to the new forms created by the form(as far as i know) when i change the stack style, i restart the program.This is the code of the 3 buttons:


<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Private <span style="color:Blue; Sub Right_Click <span style="color:Green; button1
setting.Stack = <span style="color:#A31515; "Right"
setting.Save()
Process.Start(Application.ExecutablePath)
<span style="color:Blue; Me.Close()
[/code]
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; Private <span style="color:Blue; Sub Left_Click <span style="color:Green; button2
setting.Stack = <span style="color:#A31515; "Left"
setting.Save()
Process.Start(Application.ExecutablePath)
<span style="color:Blue; Me.Close()
<span style="color:Blue; End <span style="color:Blue; Sub
<span style="color:Blue; Private <span style="color:Blue; Sub Free_Click <span style="color:Green; button3
setting.Stack = <span style="color:#A31515; "Free"
setting.Save()
Process.Start(Application.ExecutablePath)
<span style="color:Blue; Me.Close()
<span style="color:Blue; End <span style="color:Blue; Sub
[/code]

Now the problem.This code works only after clicking once, any of these buttons.To explain, when i load the app, the new forms
get the stack style that they were when last closed the app(lets say they are on the right of the screen), but when i click button2, there are two cases:Case 1 , stackstyle stays the same .Case 2 , stackstyle goes free (instead of left, becouse of button2
code).This happens no matter what stakstyle is On when the program starts...it just never does the proper action at the first time.After that, everything works perfect.
I suspect that the problem is coused by this: <span style="white-space:pre Process.Start(Application.ExecutablePath)
<span style="white-space:pre Can anyone help me? <hr class="sig Save it!

View the full article
 

Similar threads

D
Replies
0
Views
110
Donald Uko
D
P
Replies
0
Views
131
programmervb.net
P
K
Replies
0
Views
228
Khan345
K
D
Replies
0
Views
109
Donald Uko
D
Back
Top