Public Shared Function GetPeriodrun(ByVal strRevision As String) As DataTable
Dim dt As New DataTable
Using db As New Oracle(BaseModel.GetConnectionString("AVO"))
db.OpenConnection()
Dim strSql As New System.Text.StringBuilder
strSql.AppendLine(" SELECT SUBSTR(MAX(TPC_REVISION),1,3)||SUBSTR(MAX(TPC_REVISION),4,2)+1||'XX' ")
strSql.AppendLine(" FROM TAXC_PERIOD_CTRL T")
strSql.AppendLine(" WHERE TPC_REVISION ='" & strRevision & "'")
strSql.AppendLine(" GROUP BY TPC_REVISION")
db.CreateCommand(strSql.ToString, CommandType.Text)
dt = db.ExecuteReader()
db.CloseConnection()
End Using
Return dt
End Function
Function PlusIntStr(ByVal S As String, Start As Integer, ChrLen As Integer, Number As Integer) As String
With S
Return .Insert(3, Format(Int(.Substring(Start - 1, ChrLen)) + Number, StrDup(ChrLen, "0"))).Remove((Start - 1) + ChrLen, ChrLen)
End With
End Function
MsgBox(PlusIntStr("A1803XX", 4, 2, 1))
เขียน command text ไม่เป็น เลยเขียนฟังค์ชั่น
ฟังชั่นจะ error เมื่อเลขเกิน 99 นะ