VB.NET剩余函数

Cha*_*nst 0 vb.net

我想要做的是每50个字符串读取一行文本.我试图在interger上找到一个reaminder函数GlobalVariables.TransferTracker,但我在网上找不到任何东西.有没有这样的功能?或者不同/更好的方法来做到这一点?如果它有帮助,这是我的代码:

       Do While TransferRecord.Read()

            'Start of writing to the SQL server.
            SQLServerConnection.Open()

            'SQL statement to transfer all the data that fits the requirements to the SQL server.
            Dim SQLCommand1 As New SqlCommand("INSERT INTO dbo.b_Pulp_PI_Forte (" & _
                                              "mill, " & _
                                              "keyprinter_datetime, " & _
                                              "bale_line_num, " & _
                                              "pulp_line_id, " & _
                                              "bale_id, " & _
                                              "drop_datetime, " & _
                                              "layboy_position, " & _
                                              "bale_gross_weight, " & _
                                              "gross_value_flag, " & _
                                              "bale_airdry_pct, " & _
                                              "airdry_value_flag, " & _
                                              "sheets_per_bale, " & _
                                              "grader_test_flag, " & _
                                              "dropped_num, " & _
                                              "created_by, " & _
                                              "CreatedDateTime, " & _
                                              "Who_did_it, " & _
                                              "Last_change_datetime) " & _
                                              "VALUES (" & _
                                              "'850', " & _
                                              "'" & ProdDate & "', " & _
                                              "'" & BaleLineNum & "', " & _
                                              "'" & BaleLine & "', " & _
                                              "'" & BaleNumber & "', " & _
                                              "'" & ProdDate & "', " & _
                                              "'0', " & _
                                              "'" & GrossWeight & "', " & _
                                              "'" & GrossWeightFlag & "', " & _
                                              "'" & AirDry & "', " & _
                                              "'" & AirDryFlag & "', " & _
                                              "'0', " & _
                                              "'N', " & _
                                              "'0', " & _
                                              "'BaleTrac', " & _
                                              "'" & Date.Now & "', " & _
                                              "'BaleTrac', " & _
                                              "'" & Date.Now & "')")

            'If DisplayCode is checked this will be printed to the screen.
            If ApplicationPropertiesWindow.DisplayCodechkbx.Checked = True Then
                MainTextBox.AppendText(Environment.NewLine & SQLCommand1.CommandText)
                GlobalVariables.DisplayCode = True
            End If

            'Executing the SQL statement.
            SQLCommand1.Connection = SQLServerConnection
            SQLCommand1.ExecuteNonQuery()
            SQLServerConnection.Close()
            GlobalVariables.TransferTracker = GlobalVariables.TransferTracker + 1

            'This is where I would like to have the remainder function.
            'Making message to show that program is still running.
            If GlobalVariables.TransferTracker = 50 Then
                MainTextBox.AppendText(Environment.NewLine & "50 records transferred.")
            End If
        Loop
Run Code Online (Sandbox Code Playgroud)

现在我只是设置它所以它将触发50条记录,因为我找不到该功能.

Kon*_*lph 7

余数是VB中的运算符Mod:

If GlobalVariables.TransferTracker Mod 50 = 0 Then …
Run Code Online (Sandbox Code Playgroud)

作为一般建议,不要写… = True在你的条件.它的冗余是多余的.