追蹤
ˊ-橙色九月-ˊ
關於部落格
  • 33150

    累積人氣

  • 6

    今日人氣

    0

    追蹤人氣

VB15

call open(1,2,3)
回傳值(計算結果)具備型態
Sub oper (ByVal a as Integer) As Integer
變數、函數、參數都需要宣告型態
Integer、Double、String
內建函數
Mid(原資料、開始位置、擷取長度)=>文字(字串)
InStr(原資料、比對資料)=>整數
CInt(原資料)
Format(原資料、格式)
語法
Select case 變數(值)
case...
case...
case...
End Select
副程式
Sub 函數名稱
(ByVal a As Integer, ByVal b As Integer)As Integer
XXXX程式碼
End Sub

身份證檢查
Function idchk (ByVal idv As String, ByVal)
Dim s As String
Dim i As Integer
Dim x1,x2 As Integer
Dim sum As Integer
'判斷為2碼與性別
s=Mid(idv,2,1)
If((s="1" AND Settype="M") or (s="2" AND Settype="F"))
If Not(cs="1" and settype="M")or(s="2" and settype="f"))then
idchk="SEX ERROR"
Exit Function
End If
i=Instr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",LEFT(idv,1))+9
1*x1=i10
9*x2=(i Mod 10)
sum=x1+9*x2+VAL(Right(idv,1))'VA:轉換數字函數
For i = 2 to 9
sum=sum+(10-i)*VAL(Mid(idv,i,1))
Next
If(sum Mod 10)=0 then
idchk=""
else
idchk="check sum ERROR"
End If
settype As String )As string
英文
A~Z
A=10
=>代表數字=位置+9
例:B123456789
B=11 123456789
10-23456789
加起來和/10可整除


Dim rec As Integer
Dim id , vname , sex As String
rec=0
open "d=940306.sm" For Input As #1
With msg
ROW=0 : . Colwidth(0)=100
Col=1: . text="ID_NO": . Colwidth(1)=1600
Col=2: . text="Mnme": . Colwidth(2)=1200
Col=3: . text="sex": . Colwidth(3)=500
Col=4: . text="error": . Colwidth(4)=2000
End With
Do
Input #1 , id , vname ,sex
rec=rec+1
with msg
。Rows=rec+1
。Row=rec
。Col=1: . text=id
。Col=2: .text=vnane
。Col=3: .text=sex
。Col=4: .text=idchk(id,sex)
End With
Loop until FoF(1)
msg.Col =1
msg.Sort=5
 

相簿設定
標籤設定
相簿狀態