Minggu, 09 Januari 2011

nilai max vb.net

Private Sub auto()
        cnn = New OleDbConnection(strConn)
        If cnn.State <> ConnectionState.Closed Then cnn.Close()
        cnn.Open()


        Dim strTemp As String = ""
        Dim strValue As String = ""
        Dim sql As String
        Dim temp1 As String = ""
        temp1 = Mid(Year(Now), 3, 2)

        sql = "SELECT * from PO ORDER BY No_PO DESC"
        cmmd = New OleDbCommand(sql, cnn)
        dReader = cmmd.ExecuteReader
        If dReader.Read Then
            strTemp = Mid(dReader.Item("NO_PO"), 5, 4)


        Else

            txtNo_PO.Text = "PO" & temp1 & "0001"
            Exit Sub
        End If


        strValue = Val(strTemp) + 1
        txtNo_PO.Text = "PO" & temp1 & Mid("0000", 1, 4 - strValue.Length) & strValue

        cnn.Close()

    End Sub

Tidak ada komentar:

Posting Komentar