Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Code debug...

Posted on 2012-03-11
2
248 Views
Last Modified: 2012-06-27
The attached code shows a simple form with one text box and one button to enter a name and to show a welcome message when the button is clicked.

It works okay but sometimes errors at the End command at line marked by '*********

The code was created using vs2008 and I am running it in vs2010.

Question1: Is this command (End)no longer valid in vs2010?

Error:  Win32Exception was unhandled;  Error creating window handle

Thank you.

code:
Public Class frmWelcomeStudent

    Private Sub cmdWelcome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdWelcome.Click

        Dim intResponse As Integer
        Dim strMsg As String
        Dim strTitle As String
        Dim strName As String

        'store student name after triming the blank spaces either side
        strName = Trim(txtUserName.Text)

        'check to see if user name is left blank
        If Len(strName) = 0 Then

            MessageBox.Show("Please enter a name.", "User Name Is Blank...")
            txtUserName.Focus()
            txtUserName.SelectAll()

        Else

            'check to see at least the first char is "A" thru "z"
            If strName.Substring(0, 1) >= "A" And strName.Substring(0, 1) <= "z" Then

                strMsg = "Welcome to CS 19 '" & strName & "'." & vbNewLine & vbNewLine & _
                         "Do you want to exit?"

                strTitle = "Message To Student..."

                intResponse = MessageBox.Show(strMsg, strTitle, MessageBoxButtons.YesNo, _
                              MessageBoxIcon.Question)

                If intResponse = vbYes Then
                    End  '***************************
                Else

                    txtUserName.Clear()
                    txtUserName.Focus()

                End If
            Else

                MessageBox.Show("Please enter a name starting with a letter.", "User Name '" & _
                                 strName & "' Not Valid...")
                txtUserName.Focus()
                txtUserName.SelectAll()

            End If

        End If

    End Sub

End Class
0
Comment
Question by:Mike Eghtebas
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37708372
Instead of "End", you could use "Application.Exit".  A less harsh option would be to close the main form with Close() so that the application exits normally.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 37708484
Hi Idle_Mind,

You probably recall while back I was looking to simulate a fuel gauge:

For example:
Drive 60 miles
Gas use 30 miles/gal
Fuel gauge shows 15 Gal.
Upon a click on "Drive" button, the indicator arm swings from 15 down to 13 gal.

Later on, to make it more complex, one can add velocity parameter for the fuel gauge operate like an analog instrument. But that is for much later.

Recently I took some Java course and did a similar animation (simulation). But with this fuel gauge I will need you help. I also am about to start a database development job so I will be able to visit your profile often.

Regards,

Mike
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question