Change the words YourChildFormName to the actual string name of your child form. Change the words YourChildForm to your acutal ChildForm object and the words YourParentForm to your actual MDI form object.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Launch if it wasn't found
Often times when developing application and using panels, getting a control to receive startup focus can be somewhat of a pain. After much trial and error and a lot of online research into the problem, I finally found a solution that worked.
In my example I will show you how I overcame this problem using the form load event.
Private Sub Form1(ByVal sender As Object, ByVal e as System.EventArgs) Handles Me.Load
The key to this method is to call the focus event then the select event. I added the SelectAll for my own personal preference.
There are a couple of ways to do this but the basic principle is the same. Here are a couple of ways to do this:
1) As a string function
Public Function ScreenResolution() As String
2) Broken down into two different functions
Public Function ScreenWidth() As Integer
Public Function ScreenHeight() As Integer
3) Copy and paste the below code into your own function or procedure and use it that way.
Dim X As Integer = Screen.PrimaryScreen.Bounds.Width
All you need to do is copy and past the segment of code below into the keypress event of the control.
If Asc(e.KeyChar) = Keys.Enter Then
e.Handled = True
That's it, I hope you find it useful...
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Add the code snippet above and then call the Pause() procedure
Ok, so I like the XP look of blues and greys. Here is what colors I usually use when designing forms. These are in RGB format
Light Blue - 178, 203, 242
Med Blue - 118, 144, 197
Dark Blue - 51, 102, 204
Light Grey - 241, 242, 242
Hey, do what you want. I just like it ok :-)
I wanted to store my form names in a table for a SQL Reporting Application I was working on. Criteria forms weren't always required for the reports but when they were available I wanted to pull the form name from the menu table and call a simple procedure to load the form. This would have been very easy to do in VB6 but I was at a total loss in VB.Net to accomplish this task. Finally in a forum post soemeone told just how simple this is and I wanted to share it with you and also provide a link to the forum on which I picked it up. The code works like this
'Create a class just copy and paste the code below into a blank class file
'*******Begin Code for class file***************************
Public Class ObjectFinder
Dim obj As Object
obj = [Assembly].GetEntryAssembly.CreateInstance(objectName)
Catch ex As Exception
Public Shared Function CreateForm(ByVal formName As String) As Form
'*******End Code for Class file**************************
'Then all you need to do is call the function like this...
' Dim frm As Form
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Catch ex As Exception
'With a small amount of work, you can use more defined types of catch errors and apply different messages that will make more sense to you instead of the standard exception has occurred. You can have as many catch lines as you want for each kind of error.
In order to check for an internet connection you need to use the Windows API function InternetGetConnectedState which returns either true or false. You can also get the connection type from the dwFlags parameter. In our example I will popup a dialog box but you can do what ever you deem necessary with the results according to your specific needs.
'Declare the API function
Private Declare Function InternetGetConnectedState Lib "wininet" _
'Define possible connection types
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If blnConnected Then
'Display the connection flags
'This code does not verify that a connection is active just that the computer is currently configured for the internet.
VB.Net makes this a short task with the System.Diagnostics class. One line of code can get this working for you in a click event or you can setup a sub procedure and just send the path to the exe file.
'Just copy and paste this procedure into your code and then just call it
Public Sub LoadFile(ByVal Path as String)
'Launches the fhe file as long as the system has
'the application to open it
'Just copy and paste the one line below into your Click event and
'change the word Path to the full path to the file you are wanting to launch
I hope you find some use for this tip.