what did I miss?

  • Thread starter Thread starter jg
  • Start date Start date
J

jg

I setup a new windwos application project but I found out the sub main was
not called, I tried various form of Main (functions, subs) still no luck.
What did I miss?

Public Class SolverForm
Dim icnt_pieces = 0, iCurrent_Row = 0, iExpected_pieces = 16, i As
Integer
Dim ipb_piece() As PictureBox
Dim str_label() As String
Dim chr_Atrribute(iExpected_pieces)() As Char
Dim chr_AtrributeFlip(iExpected_pieces)() As Char
Dim b_used() As Boolean

Dim ipb_origin_location As System.Drawing.Point
Dim ipb_origin_offset As Integer = 106

Const CSTR_LABEL As String = "ABCDEFGHIJKLMNOPQRSTUVZ0123456789"

Public Function Main(ByVal cmdArgs() As String) As Integer

MsgBox("MAIN - before new Game", MsgBoxStyle.Information, "@debug") ' never
appear
NewGame()
ipb_piece(0) = PictureBox1
ipb_piece(1) = PictureBox2
ipb_piece(2) = PictureBox3
ipb_piece(3) = PictureBox4
......
ipb_piece(15) = PictureBox16
MsgBox("MAIN - before calling rect", MsgBoxStyle.Information,
"@debug")
testRectangle()

End Function
 
jg said:
I setup a new windwos application project but I found out the sub
main was not called, I tried various form of Main (functions, subs)
still no luck. What did I miss?

[...]

Public Function Main(ByVal cmdArgs() As String) As Integer

Shared function Main...


And set it as the startup object in the project properties.


Armin
 
As Armin suggested, you need to make Maim shared but if you do it in place
it will cause other problems. Add a Form_Load event handler to SolverForm,
copy all the code from Main to Form_Load and delete Main then add this
class:

Public Class AppStart
Public Shared Sub Main()
Application.Run(New SolverForm())
End Sub
End Class

Then, set the startup object to AppStart.Main
 
Hi,

Isn't it sub main to startup from not function main?

Ken
----------------
Armin Zingler said:
jg said:
I setup a new windwos application project but I found out the sub
main was not called, I tried various form of Main (functions, subs)
still no luck. What did I miss?
[...]

Public Function Main(ByVal cmdArgs() As String) As Integer

Shared function Main...


And set it as the startup object in the project properties.


Armin
 
Ken Tucker said:
Isn't it sub main to startup from not function main?

It will work with a function 'Main(ByVal Args() As String) As Integer' too,
even inside VS.NET.
 
thank you all very much. . I look up the form load declaration.

why constructor does not work instead of this extra complexity? After all
is not a window app a class by in its own right?
( pardon me I am used to languages with constructors)

Rob Windsor said:
As Armin suggested, you need to make Maim shared but if you do it in place
it will cause other problems. Add a Form_Load event handler to SolverForm,
copy all the code from Main to Form_Load and delete Main then add this
class:

Public Class AppStart
Public Shared Sub Main()
Application.Run(New SolverForm())
End Sub
End Class

Then, set the startup object to AppStart.Main

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
http://msmvps.com/windsor/


jg said:
I setup a new windwos application project but I found out the sub main was
not called, I tried various form of Main (functions, subs) still no luck.
What did I miss?

Public Class SolverForm
Dim icnt_pieces = 0, iCurrent_Row = 0, iExpected_pieces = 16, i As
Integer
Dim ipb_piece() As PictureBox
Dim str_label() As String
Dim chr_Atrribute(iExpected_pieces)() As Char
Dim chr_AtrributeFlip(iExpected_pieces)() As Char
Dim b_used() As Boolean

Dim ipb_origin_location As System.Drawing.Point
Dim ipb_origin_offset As Integer = 106

Const CSTR_LABEL As String = "ABCDEFGHIJKLMNOPQRSTUVZ0123456789"

Public Function Main(ByVal cmdArgs() As String) As Integer

MsgBox("MAIN - before new Game", MsgBoxStyle.Information, "@debug") '
never appear
NewGame()
ipb_piece(0) = PictureBox1
ipb_piece(1) = PictureBox2
ipb_piece(2) = PictureBox3
ipb_piece(3) = PictureBox4
.....
ipb_piece(15) = PictureBox16
MsgBox("MAIN - before calling rect", MsgBoxStyle.Information,
"@debug")
testRectangle()

End Function
 
You can use the constructor if you want. People coming from a classic VB
background (like myself) are just used to putting the form initialization
code in the Load event.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
http://msmvps.com/windsor/

jg said:
thank you all very much. . I look up the form load declaration.

why constructor does not work instead of this extra complexity? After
all is not a window app a class by in its own right?
( pardon me I am used to languages with constructors)

Rob Windsor said:
As Armin suggested, you need to make Maim shared but if you do it in
place it will cause other problems. Add a Form_Load event handler to
SolverForm, copy all the code from Main to Form_Load and delete Main then
add this class:

Public Class AppStart
Public Shared Sub Main()
Application.Run(New SolverForm())
End Sub
End Class

Then, set the startup object to AppStart.Main

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
http://msmvps.com/windsor/


jg said:
I setup a new windwos application project but I found out the sub main
was not called, I tried various form of Main (functions, subs) still no
luck. What did I miss?

Public Class SolverForm
Dim icnt_pieces = 0, iCurrent_Row = 0, iExpected_pieces = 16, i As
Integer
Dim ipb_piece() As PictureBox
Dim str_label() As String
Dim chr_Atrribute(iExpected_pieces)() As Char
Dim chr_AtrributeFlip(iExpected_pieces)() As Char
Dim b_used() As Boolean

Dim ipb_origin_location As System.Drawing.Point
Dim ipb_origin_offset As Integer = 106

Const CSTR_LABEL As String = "ABCDEFGHIJKLMNOPQRSTUVZ0123456789"

Public Function Main(ByVal cmdArgs() As String) As Integer

MsgBox("MAIN - before new Game", MsgBoxStyle.Information, "@debug") '
never appear
NewGame()
ipb_piece(0) = PictureBox1
ipb_piece(1) = PictureBox2
ipb_piece(2) = PictureBox3
ipb_piece(3) = PictureBox4
.....
ipb_piece(15) = PictureBox16
MsgBox("MAIN - before calling rect", MsgBoxStyle.Information,
"@debug")
testRectangle()

End Function
 
Thank you.

how do I make sure what I do is after the form is fully created and loaded?
e.g I want to get hold of the list of picture boxes and have an array of
picture box to point to them. this way I can manipulate the content of the
picturebox a bit easier.


The load event seem to occur before completion. I tried searching for form
events for vb.net and I got overwhelming irrelevant results.

Rob Windsor said:
You can use the constructor if you want. People coming from a classic VB
background (like myself) are just used to putting the form initialization
code in the Load event.

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
http://msmvps.com/windsor/

jg said:
thank you all very much. . I look up the form load declaration.

why constructor does not work instead of this extra complexity? After
all is not a window app a class by in its own right?
( pardon me I am used to languages with constructors)

Rob Windsor said:
As Armin suggested, you need to make Maim shared but if you do it in
place it will cause other problems. Add a Form_Load event handler to
SolverForm, copy all the code from Main to Form_Load and delete Main
then add this class:

Public Class AppStart
Public Shared Sub Main()
Application.Run(New SolverForm())
End Sub
End Class

Then, set the startup object to AppStart.Main

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
http://msmvps.com/windsor/


I setup a new windwos application project but I found out the sub main
was not called, I tried various form of Main (functions, subs) still no
luck. What did I miss?

Public Class SolverForm
Dim icnt_pieces = 0, iCurrent_Row = 0, iExpected_pieces = 16, i As
Integer
Dim ipb_piece() As PictureBox
Dim str_label() As String
Dim chr_Atrribute(iExpected_pieces)() As Char
Dim chr_AtrributeFlip(iExpected_pieces)() As Char
Dim b_used() As Boolean

Dim ipb_origin_location As System.Drawing.Point
Dim ipb_origin_offset As Integer = 106

Const CSTR_LABEL As String = "ABCDEFGHIJKLMNOPQRSTUVZ0123456789"

Public Function Main(ByVal cmdArgs() As String) As Integer

MsgBox("MAIN - before new Game", MsgBoxStyle.Information, "@debug") '
never appear
NewGame()
ipb_piece(0) = PictureBox1
ipb_piece(1) = PictureBox2
ipb_piece(2) = PictureBox3
ipb_piece(3) = PictureBox4
.....
ipb_piece(15) = PictureBox16
MsgBox("MAIN - before calling rect", MsgBoxStyle.Information,
"@debug")
testRectangle()

End Function
 
Back
Top