Private Sub Runnumber()
Dim MaxID As Double
Con.Open()
Cmd = New SqlCommand()
With Cmd
.Connection = Con
.CommandText = "SELECT MAX (Right(goodsID,3)) FROM GoodsReceive"
If IsDBNull(.ExecuteScalar()) = True Then
MaxID = 1
Else
MaxID = .ExecuteScalar() + 1
End If
txtautonum.Text = MaxID.ToString("000")
End With
Con.Close()