標籤雲
2009年3月25日 星期三
2009年3月20日 星期五
VB LEARNING: 上課教材
數字轉國字大寫 -- 精簡版
'數字轉國字大寫 -- 精簡版
Public Class Form1
Dim i
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim s1 = "123450"
Dim r1 = "拾佰仟萬拾佰仟億拾佰仟兆"
Dim n = Len(s1)
Dim s2 = Mid(s1, n, 1)Dim j = 1
For i = n - 1 To 1 Step -1
s2 = Mid(s1, i, 1) & Mid(r1, j, 1) & s2
j = j + 1
Nexts2 = Replace(s2, "1", "壹")
s2 = Replace(s2, "2", "貳")
s2 = Replace(s2, "3", "參")
s2 = Replace(s2, "4", "肆")
s2 = Replace(s2, "5", "伍")
s2 = Replace(s2, "6", "陸")
s2 = Replace(s2, "7", "柒")
s2 = Replace(s2, "8", "捌")
s2 = Replace(s2, "9", "玖")
s2 = Replace(s2, "0", "零")s2 = Replace(s2, "零拾", "零")
s2 = Replace(s2, "零佰", "零")
s2 = Replace(s2, "零仟", "零")s2 = Replace(s2, "零零零", "零")
s2 = Replace(s2, "零零", "零")If Mid(s2, Len(s2), 1) = "零" Then s2 = Mid(s2, 1, Len(s2) - 1)
If s2 = "" Then s2 = "零"MsgBox(s2)
End Sub
End Class
VB LEARNING: 上課教材
井宇遊戲 - 人與電腦對戰版 2008/03/11
'井宇遊戲 - 人與電腦對戰版
' 電腦每次用亂數法,下一個尚未被使用的格子
Public Class Form1
Dim btn(9) As Button, i As Integer
Dim oxFlag As Boolean
Dim sco(9) As Integer
Dim no As IntegerPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call prepare()no = Int(Rnd() * 9) + 1
Call playOne()
End Sub:
:
VB LEARNING: 上課教材
井字遊戲 -- 二種電腦邏輯對戰版
'二種電腦邏輯對戰版
'○採用由第1至第9格,依序找一個可以下的格子就下的方法
'×採用由第1至第9格,隨機方式找一個可以下的格子就下的方法
Public Class Form1
Dim btn(9) As Button
Dim i
Dim j
Dim sco(9)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
btn(1) = Button1:
:
2009年3月6日 星期五
2009年3月5日 星期四
數字轉國字大寫 -- 精簡版
'數字轉國字大寫 -- 精簡版
Public Class Form1
Dim i
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim s1 = "123450"
Dim r1 = "拾佰仟萬拾佰仟億拾佰仟兆"
Dim n = Len(s1)
Dim s2 = Mid(s1, n, 1)Dim j = 1
For i = n - 1 To 1 Step -1
s2 = Mid(s1, i, 1) & Mid(r1, j, 1) & s2
j = j + 1
Nexts2 = Replace(s2, "1", "壹")
s2 = Replace(s2, "2", "貳")
s2 = Replace(s2, "3", "參")
s2 = Replace(s2, "4", "肆")
s2 = Replace(s2, "5", "伍")
s2 = Replace(s2, "6", "陸")
s2 = Replace(s2, "7", "柒")
s2 = Replace(s2, "8", "捌")
s2 = Replace(s2, "9", "玖")
s2 = Replace(s2, "0", "零")s2 = Replace(s2, "零拾", "零")
s2 = Replace(s2, "零佰", "零")
s2 = Replace(s2, "零仟", "零")s2 = Replace(s2, "零零零", "零")
s2 = Replace(s2, "零零", "零")If Mid(s2, Len(s2), 1) = "零" Then s2 = Mid(s2, 1, Len(s2) - 1)
If s2 = "" Then s2 = "零"MsgBox(s2)
End Sub
End Class
2009年3月4日 星期三
數字轉國字 -- 加位數單位
Public Class Form1
Dim i, str1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim s1 = "1234567"
Dim s2 = "拾佰仟萬拾佰仟億"
str1 = Mid(s1, Len(s1), 1)
For i = Len(s1) - 1 To 1 Step -1
str1 = Mid(s1, i, 1) & Mid(s2, Len(s1) - 1 + 1 - i, 1) & str1
Next
MsgBox(str1)
End Sub
End Class