Results 1 to 3 of 3

Thread: [2005] Code warnings

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    London United Kingdom
    Posts
    334

    Resolved [2005] Code warnings

    Hi I have this code and function which shows no warnings in vs 2003 but showing warnings in vs 2005. This code shows the following warning(Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.)
    Code:
       Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
            Dim iResult As DialogResult = MessageBox.Show("Delete " & cboUsers.Text & "?", _
            "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            If iResult = DialogResult.Yes Then
                drUsers.Delete()
                cboUsers.Focus()
            End If
        End Sub
    This function also show this warning (Variable 'sErrorMessage' is used before it has been assigned a value. A null reference exception could result at runtime.)
    Code:
       Private Function ValidData() As Boolean
            Dim sErrorMessage As String
            If txtFirstName.Text = "" Then
                sErrorMessage = "Please First Name required"
            ElseIf txtSurname.Text = "" Then
                sErrorMessage = "Please Surname required"
            ElseIf txtUserName.Text = "" Then
                sErrorMessage = "Please User Name required"
            ElseIf txtPosition.Text = "" Then
                sErrorMessage = "Please Possition required"
            ElseIf txtEmployeeNo.Text = "" Then
                sErrorMessage = "Please Employee number reqired"
            End If
            If sErrorMessage = "" Then
                ValidData = True
            Else
                ValidData = False
                MessageBox.Show(sErrorMessage, "Data entry error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End Function
    The bold words in the codes are underline in my code. Could any one help out. Thanks
    Last edited by wiadus; Apr 14th, 2007 at 07:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width