Well,
First:
daveofgv said:
public Class NeedInternet
Private Sub Main_FormClosing(ByVal sender As Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles Me.FormClosing
e.Cancel = ShowSplashForm()
End Sub
And I am placing the snippet at the top in the Class section correct????
The Main_FormClosing Event should be in the Main.vb file attached to the Main Class. and teh NeedInternet_Load should be in the NeedInternet.vb in the NeedInternet Class, and second the snippet doesn't care "where" it is placed, at least within the Class. yes the code I offered is a Class Method for the Forms you were working with.
Secondly:
daveofgv said:
If My.Settings.donotshowagainlaw = False Then
NeedInternetLaw.Show()
Else
If My.Settings.donotshowagainlaw = True Then
This code here will definitely work, but some of that is thanks to VB. Now, this is most definitely a
personal preference, but it flows into all aspects of programming in my mind, which is why I feel it necessary to comment.
The Boolean type (in most every language) is basically a Bit, but for binary alignment it is expanded into a byte, must often an unsigned 8 bit integer, though you will see here that VB does not follow that pattern. For VB they do something idiotic by making "True" equate to the numerical value -1, and False = 0. If you understand how bits/bytes work within a computer you can see the fallacy behind this.
Take a simple 16 bit Short (Short Integer, or Word) as aligned within a computer. An Unsigned Short is 0-65535, a Signed Short is -32768-32767. But the question of how it is written in bits is complicated (and I don't quite remember it all for it has been years). But 0 to 65535 is simple, because it is 00000000-00000001 = 1 but for the Signed Short:
11111111-11111111 = -1, and that's where the confusion can set in. Within the Boolean Logic as well as Bitwise logic of the computer it is helpful to recognize this when working with VB as opposed to other languages, however, it should be noted that all languages interpret 0 as false and (Not-0) as true, thus going back to Boolean Logic 101:
If (Not False) = (True)
If (Not True) = (False)
thus, my personal preference is to always reference boolean's as a boolean and not as a "Equation", as some languages cannot compare False to False, and even further to remember that a database can never compare NULL to NULL,
DB: If NULL = NULL : is False because Null(0) is False
SO I tend to recommend that boolean should be treated the same:
If ([U]Not My.Settings.DoNotShowAgain[/U]) then
elseif [U]My.Settings.DoNotShowAgain[/U] then
end if
Which leads me to the depiction of the obvious. If the type is Boolean, it can only contain two values, True or False, thus the double statement is quite unnecessary. With Modern optimizers they may catch it, and eliminate the double statement, but I never trust a computer to do my job (*chuckle*).
looking at the statement above, that does two identical comparisons that the compiler may catch. However your statement:
1: if Not X then
else
2: If X then
end if
end if
uses an "compound" statement within the "false" execution of the primary If block. when the "If Not X" is evaluated, if it fails, the "else" section is executed, and the first statement of that block is another "If X", but since you are using the same variable for both blocks you are in turn forcing the compiler to evaluate the same variable twice and the optimizer most likely won't catch it, so when the program runs it must execute two different comparison evaluations to achieve its end.
If My.Settings.DoNotShowAgain then
DoTrueCode()
else
DoFalseCode()
end if
the Above achieves the exact same result as yours, but with only one Boolean evaluation. At the moment, this is not a vast importance or necessity within the grand scheme of your application, since with modern processors you'd never notice the difference. However, recognizing the good coding practice, you could extrapolate a 10,000,000 line program, with say 500,000 Boolean evaluations, if every Boolean Evaluation was done twice, that would be 1,000,000 calculations to resolve what only needed 500,000 and the slow down might then become apparent.
As much as I hated them, and personally find them useless, I'd recommend looking into some logic flow charts again, and researching some of the basics of programming. I personally find VB to not be the best teacher of programming, since it allows too many oversights on the part of the programmer, trying to fix what we are supposed to know and do by right.
All that being said, the final product of your design should work, given that the Main Form's Events are all handled in the Main.Vb file and the NeetInternet Form's Events are all handled in the NeetInternet.vb file.
Hope this helps.