網路城邦
回本城市首頁 唐老鴨之家
市長:  副市長:
加入本城市推薦本城市加入我的最愛訂閱最新文章
udn城市資訊科技網路分享【唐老鴨之家】城市/討論區/
討論區Excel VBA 字體:
上一個討論主題 回文章列表 下一個討論主題
身分證字號產生器VBA程式
 瀏覽1,251|回應0推薦0


等級:6
留言加入好友
Rem === 身分證字號產生器VBA程式 ===
Rem === 使用元件:CommandButton1,2, ComboBox1, OptionButton1(Male),2(Female), TextBox1

Dim id(10) As Integer

Private Sub CommandButton1_Click() '產生身分證號
Select Case ComboBox1.ListIndex
Case 0: vv = "10"
Case 1: vv = "11"
Case 2: vv = "12"
Case 3: vv = "13"
Case 4: vv = "14"
Case 5: vv = "15"
Case 6: vv = "16"
Case 7: vv = "17"
Case 8: vv = "34"
Case 9: vv = "18"
Case 10: vv = "19"
Case 11: vv = "20"
Case 12: vv = "21"
Case 13: vv = "22"
Case 14: vv = "35"
Case 15: vv = "23"
Case 16: vv = "24"
Case 17: vv = "25"
Case 18: vv = "26"
Case 19: vv = "27"
Case 20: vv = "28"
Case 21: vv = "29"
Case 22: vv = "32"
Case 23: vv = "30"
Case 24: vv = "31"
Case 25: vv = "33"
End Select
id(0) = Val(Left(vv, 1))
id(1) = Val(Right(vv, 1))
vv2 = id(0) + 9 * id(1)
If OptionButton1.Value = True Then
id(2) = 1
Else
id(2) = 2
End If
vv2 = vv2 + 8 * id(2)
Randomize
For I = 3 To 9
id(I) = Int(Rnd * 10)
vv2 = vv2 + (10 - I) * id(I)
Next I
id(10) = 10 - vv2 Mod 10
If id(10) = 10 Then id(10) = 0
TextBox1.Text = Left(ComboBox1, 1) & id(2) & id(3) & id(4) & id(5) & id(6) & id(7) & id(8) & id(9) & id(10)
End Sub

Private Sub CommandButton2_Click() '選單重設
ComboBox1.AddItem "A台北市"
ComboBox1.AddItem "B台中市"
ComboBox1.AddItem "C基隆市"
ComboBox1.AddItem "D台南市"
ComboBox1.AddItem "E高雄市"
ComboBox1.AddItem "F台北縣"
ComboBox1.AddItem "G宜蘭縣"
ComboBox1.AddItem "H桃園縣"
ComboBox1.AddItem "I嘉義市"
ComboBox1.AddItem "J新竹縣"
ComboBox1.AddItem "K苗栗縣"
ComboBox1.AddItem "L台中縣"
ComboBox1.AddItem "M南投縣"
ComboBox1.AddItem "N彰化縣"
ComboBox1.AddItem "O新竹市"
ComboBox1.AddItem "P雲林縣"
ComboBox1.AddItem "Q嘉義縣"
ComboBox1.AddItem "R台南縣"
ComboBox1.AddItem "S高雄縣"
ComboBox1.AddItem "T屏東縣"
ComboBox1.AddItem "U花蓮縣"
ComboBox1.AddItem "V台東縣"
ComboBox1.AddItem "W金門縣"
ComboBox1.AddItem "X澎湖縣"
ComboBox1.AddItem "Y陽明山"
ComboBox1.AddItem "Z連江縣"
ComboBox1.ListIndex = 0
End Sub
回應 回應給此人 推薦文章 列印 加入我的文摘

引用
引用網址:https://city.udn.com/forum/trackback.jsp?no=58536&aid=5035809