CoachBarker
Well-known member
- Joined
- Jul 26, 2007
- Messages
- 133
- Programming Experience
- 1-3
When I turn Option Strict On in a form, I received some errors, most of them I have been able to correct. I have a method to fill the controls in a form this is a shorten version of the code
The problem I can't resolve is with the Check Boxes, the first error is this;

Resolved by using IS as directed, the second error is this;

Not sure what to do here, any help
Thanks
CoachBarker
VB.NET:
' Method Name: fill
' Purpose: To fill the controls on the form
' Parameters: None
Public Sub fill()
Try
If dsForm.Tables(0).Rows.Count > 0 Then
intglucoseLevelID = CInt(dsForm.Tables(0).Rows(dbCursor).Item(0))
If Not dsForm.Tables(0).Rows(dbCursor).Item(0) Is DBNull.Value Then
Me.txtGlucoseLevelID.Text = CStr(dsForm.Tables(0).Rows(dbCursor).Item(0))
End If
' ****************************************************************
If Not dsForm.Tables(0).Rows(dbCursor).Item(1) Is DBNull.Value Then
Me.txtPatientID.Text = CStr(dsForm.Tables(0).Rows(dbCursor).Item(1))
End If
' ****************************************************************
If Not dsForm.Tables(0).Rows(dbCursor).Item(2) Is DBNull.Value Then
Me.txtDateEntered.Text = CStr(dsForm.Tables(0).Rows(dbCursor).Item(2))
End If
' ****************************************************************
If Not dsForm.Tables(0).Rows(dbCursor).Item(3) Is DBNull.Value Then
Me.txtGlucoseLevel.Text = CStr(dsForm.Tables(0).Rows(dbCursor).Item(4))
End If
' Check boxes will be in the DB as either 0 (false) or 1 (true) - no nulls
' ****************************************************************
If dsForm.Tables(0).Rows(dbCursor).Item(4) = 1 Then
Me.cbxDrankSoda.CheckState = CheckState.Checked
End If
' ****************************************************************
Else
' Check to see if there is a Glucose Level Record for this user
Dim newWeek As String = Date.Now.AddDays(-Date.Now.DayOfWeek).ToShortDateString
If (intInitialID > 0) Then
MessageBox.Show("This is the first record for the week beginning " & newWeek, "New Week")
Me.txtPatientID.Text = CStr(intInitialID)
End If
End If
hasChanged = False
Catch ex As Exception
MessageBox.Show("An error occured in frmGlucose. Method: fill. Error: " & ex.ToString)
End Try
End Sub
The problem I can't resolve is with the Check Boxes, the first error is this;

Resolved by using IS as directed, the second error is this;

Not sure what to do here, any help
Thanks
CoachBarker
Last edited: