Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15050

VS 2015 Use dataset in module public read only error

$
0
0
I have a VB.Net Windows forms application with a Dataset call LaserMaintLogDataSet. In the dataset there is a table called "Printers". I am trying to move some of the common validation routines into a Module. The module is below. The problem is I cant access the Dataset form this module. The error on dr = LaserMaintLogDataSet.Printers.FindByPrinterID(PrinterId) is "Reference to non-shared member requires object reference"

Code:

      Public Function Max_Images_Check(ByVal PrinterId As String, BegMeter As Int32, EndMeter As Int32,
                                      Login As DateTime, Logout As DateTime) As Boolean

        Dim TotalImages As Int32
        Dim decHours As Decimal
        Dim ImagesHour As Decimal
        Dim MaxImages As Integer

        Dim dr As LaserMaintLogDataSet.PrintersRow
        dr = LaserMaintLogDataSet.Printers.FindByPrinterID(PrinterId)
      MaxImages = dr.MaxImages

        If IsNumeric(BegMeter) And IsNumeric(EndMeter) Then
            If Int(EndMeter) > 0 Then
                TotalImages = CInt(EndMeter) - CInt(BegMeter)
            Else
                TotalImages = 0
            End If
        End If

        Dim Total_Hours As TimeSpan
        If IsDate(Login) And IsDate(Logout) Then
            Total_Hours = Logout.Subtract(Login)
        Else
            Total_Hours = TimeSpan.Zero
        End If

        If TotalImages > 0 And Total_Hours > TimeSpan.Zero Then
            decHours = Total_Hours.Hours + Total_Hours.Minutes / 60
            ImagesHour = TotalImages / decHours
            If ImagesHour > 10000 Then
                If (MsgBox("Total images is above the shift normal! " & vbCrLf &
                    "    Please check the meter readings.    " & vbCrLf &
                    "  Press OK to keep Cancel to revise!    ",
                    MsgBoxStyle.OkCancel, "Confirmation") = MsgBoxResult.Cancel) Then
                    Return False
                End If
            End If
        End If

        Return True

    End Function


Viewing all articles
Browse latest Browse all 15050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>