- 8月 01 週五 200821:30
畫布Graphics(VB2005)
- 7月 26 週六 200812:29
小算盤簡易版(十分簡易XDVB2005)
原始碼:down.gogobox.com.tw/t2329175/ocuo2
Public Class Form1
- 6月 28 週六 200823:13
環佇列(Circular Queue)運行系統(VB2005)
原始碼:http://down.gogobox.com.tw/t2329175/9r2m2
VB2005的物件陣列真是麻煩!
不過連我的書都沒寫!
不過好險這是常見的問題,
網路是有解答的。
原始碼如下:
'另外VB6的原始碼有做更正
Public Class Form1
Dim Queue() As Label
Dim Rear, Front, Ran, Qu(23), i As Integer
Dim Num As Integer
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
ReDim Queue(23)
For i As Integer = 0 To 5
Queue(i) = New Label
With Queue(i)
.Left = 50 + 30 * i
.Top = 60
.Width = 30
.Height = 30
.BackColor = Color.White
.BorderStyle = BorderStyle.FixedSingle
.Visible = True
Me.Controls.Add(Queue(i))
End With
Next
Num = 5
Qu(4) = 35
Qu(5) = 128
Rear = 5
Front = 4
Lr.Top = 92
Lf.Top = 48
Lastr.Text = "Now,Queue has 2 Datas."
ShowNow()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
If CanAdd(Qu, Num) = True Then
If Rear = Front And Qu(Rear) = 0 Then
Ran = 1 + Int(Rnd() * 999)
Lax.Text = "Add " & Str(Ran)
Qu(Rear) = Ran
Else
Rear = Rear + 1
If Rear > Num Then Rear = 0
Ran = 1 + Int(Rnd() * 999)
Lax.Text = "Add " & Str(Ran)
Qu(Rear) = Ran
End If
Else
If Num = 23 Then
Lax.Text = "Queue is full."
Else
For i = Num + 1 To Num + 6
Queue(i) = New Label
With Queue(i)
.Left = 50 + 30 * i
.Top = 60
.Width = 30
.Height = 30
.BackColor = Color.White
.BorderStyle = BorderStyle.FixedSingle
.Visible = True
Me.Controls.Add(Queue(i))
End With
Next
Num = Num + 6
If Front <> 0 Then
If Rear > Front And Rear < Num - 6 Then
For i = Num - 6 To Rear Step -1
Qu(i + 6) = Qu(i)
Qu(i) = 0
Next
Rear = Rear + 6
ElseIf Rear < Front Then
For i = Num - 6 To Front Step -1
Qu(i + 6) = Qu(i)
Qu(i) = 0
Next
Front = Front + 6
End If
End If
Rear = Rear + 1
If Rear > Num Then Rear = 0
Ran = 1 + Int(Rnd() * 999)
Lax.Text = "Add " & Str(Ran)
Qu(Rear) = Ran
End If
End If
ShowNow()
End Sub
Private Sub Romove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Romove.Click
If CanRomove(Qu, Num) = True Then
Lax.Text = "Romove " & Str(Qu(Front))
Qu(Front) = 0
If Front <> Rear Then
Front = Front + 1
If Front > Num Then Front = 0
End If
Else
Lax.Text = "Queue is empty."
End If
ShowNow()
End Sub
Sub ShowNow()
Dim x As Integer
For i As Int16 = 0 To Num
Queue(i).TextAlign = ContentAlignment.MiddleCenter
If Qu(i) <> 0 Then
Queue(i).Text = Qu(i)
x = x + 1
Else
Queue(i).Text = ""
End If
Next
Lr.Left = 54 + 30 * Rear
Lf.Left = 50 + 30 * Front
If x > 1 Then
Lastr.Text = "Now,Queue has " & Str(x) & " Datas."
ElseIf x = 1 Then
Lastr.Text = "Now,Queue has 1 Data."
ElseIf x = 0 Then
Lastr.Text = "Now,Queue has none."
End If
End Sub
Function CanAdd(ByVal Queue() As Integer, ByVal big As Integer) As Boolean
Dim x As Integer
CanAdd = True
For i = 0 To big
If Queue(i) = 0 Then x = x + 1
Next
If x < 2 Then CanAdd = False
End Function
Function CanRomove(ByVal Queue() As Integer, ByVal big As Integer) As Boolean
CanRomove = False
For i = 0 To big
If Queue(i) <> 0 Then CanRomove = True
Next
End Function
End Class
- 6月 27 週五 200821:01
RGB <> HSI (VB2005)
原始碼:http://down.gogobox.com.tw/t2329175/6r2m2
之前比賽時因為VB6沒有反Cos函數而飲恨,
現在有了2005不一樣了!
但我發現題目上的公式根本寫錯了!
就因為這個小錯,算出來的答案就差了255倍!
- 6月 21 週六 200810:29
質因數分解(VB2005)
原始碼:http://down.gogobox.com.tw/t2329175/7r2m2
程式碼:
Public Class Form1
Dim key, Target As Long
Private Sub Bu1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bu1.Click
- 6月 19 週四 200819:52
判斷質數(VB2005)
原始碼:http://down.gogobox.com.tw/t2329175/8r2m2
程式碼:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Num As Long, f As Boolean, x As Long, i As Long
1
