Public Function GetID() As String
Try
Dim ap1 As String
ap1 = ""
Dim i As Integer
i = 0
i = Dst.Tables("Testing").Rows.Count - 1
ap1 = Dst.Tables("Testing").Rows(i)("PatientCode").ToString
If IsDBNull(Dst.Tables("Testing").Rows(0)("PatientCode")) Then
'id = CStr(Now.Year) + 543 & "-" & "0000"
GetID = CStr(Now.Year + 543).Substring(2) & "-" & "0001"
'id = CStr(1)
Else
Dim stRef1 As String = (Now.Year + 543 - 2500).ToString("00") & "-"
Dim stNextID As String = stRef1 & "0001"
ids = Dst.Tables("Testing").Rows(0)("PatientCode")
If ids.IndexOf(stRef1) >= 0 Then
Dim n As Integer = Convert.ToInt32(ids.SubString(stRef1.Length)) + 1
stNextID = stRef1 & n.ToString("0000")
End If
GetID = stNextID
End If
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error...")
End Try
End Function
Tag : .NET, Ms Access, VBScript, VS 2010 (.NET 4.x), Windows
Public Function GetID() As String
Try
Dim ap1 As String
ap1 = ""
Dim i As Integer
i = 0
i = Dst.Tables("Testing").Rows.Count - 1
ap1 = Dst.Tables("Testing").Rows(i)("PatientCode").ToString
If ap1 = "" Then
GetID = Format(1, "000" & "/" & (Now.Year + 543))
Else
GetID = Format(Microsoft.VisualBasic.Left(ap1, 4) + 1, "000" & "/" & (Now.Year + 543))
End If
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error...")
End Try
End Function
Public Function GetID() As String
Dim objConn As New SqlConnection( conString)
objConn.Open()
Dim daAuthors As _
New SqlDataAdapter("Select * From ......", objConn)
Dim Dst As New DataSet(.......)'เราจะได้ DataSet ที่ update แล้วทุกครั้งที่เรียกใช้งาน
Try
Dim ap1 As String
ap1 = ""
Dim i As Integer
i = 0
i = Dst.Tables("Testing").Rows.Count - 1
ap1 = Dst.Tables("Testing").Rows(i)("PatientCode").ToString
If ap1 = "" Then
GetID = Format(1, "000" & "/" & (Now.Year + 543))
Else
GetID = Format(Microsoft.VisualBasic.Left(ap1, 4) + 1, "000" & "/" & (Now.Year + 543))
End If
Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error...")
End Try
End Function