We help IT Professionals succeed at work.

Learning VB

madhatter5501
madhatter5501 used Ask the Experts™
on
I am trying to learn VB and am trying to create a simple form with the following code, what am I doing wrong?  and if anyone has any input on how to learn VB I would appreciate the direction.

Public Class Form1

    Dim msg As String
    Dim title As String
    Dim style As MsgBoxStyle
    Dim response As MsgBoxResult


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

   

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Close()
    End Sub

   

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("ok", MsgBoxStyle.OkCancel)
        If MsgBoxResult.Ok Then
            Close()
                 else
                   If MsgBoxResult.Cancel Then
                   MsgBox("are you sure you want to cancel", MsgBoxStyle.YesNo)
            End If
        End If
    End Sub
End Class
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
Commented:
The common structure for asking that type of question would look like:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If MessageBox.Show("Are you sure you want to quit?", "Quitting...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            Me.Close()
        End If
    End Sub

End Class

Open in new window

Author

Commented:
only half the question was answered, the formula works good though.
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009

Commented:
...what else did you need to know?

Author

Commented:
I am looking for the best way to learn VB - Free Websites, Programs...  I'll post another link for more points since this is closed.