---
# System prepended metadata

title: VB6上課記錄2018.11.14

---


---
title: VB6上課記錄2018.11.14
description: 彰商資處科107學年度程設
image:
tags: vb6教學, dp107, dp1072
robots: noindex, nofollow
GA:
---

VB6上課記錄2018.11.14
===
![](https://i.imgur.com/1Y1IFNa.jpg)


# 感想 
好累喔!!

# 程式碼
```vba=
Private Sub cmd選擇排序法_Click()
'
    Dim a
    a = Split(Me.txt很多資料.Text)
    n = UBound(a)
    For i = 0 To n - 1
        For j = i + 1 To n
            
            If a(i) + 0 < a(j) + 0 Then
                t = a(i)
                a(i) = a(j)
                a(j) = t
            End If
                
        Next
    Next
        txtAns.Text = Join(a)
End Sub

Private Sub cmd氣泡排序法_Click()
'
    Dim a
    a = Split(Me.txt很多資料.Text)
    n = UBound(a)
    For i = 0 To n - 1
        For j = 0 To n - 1 - i
            
            If a(j) + 0 > a(j + 1) + 0 Then
                t = a(j)
                a(j) = a(j + 1)
                a(j + 1) = t
            End If
                
        Next
    Next
        txtAns.Text = Join(a)

End Sub

Private Sub cmd轉成五進位_Click()
'
    
    n = 0 + Me.lblAns.Caption
    
    Do
    r = n Mod 5
    txt數字.Text = r & txt數字.Text
    n = n \ 5
    Loop Until n = 0
    
    
End Sub

```

```vba=
Private Sub cmd畫點_Click()
'別忘了是畫在 pic1
    For i = 1 To 40
        X = Int(Rnd * pic1.ScaleWidth)
        Y = Int(Rnd * pic1.ScaleHeight)
        c = Int(Rnd * 5) + 0
        w = Int(Rnd * 4) + 1
        pic1.DrawWidth = w
        pic1.PSet (X, Y), QBColor(c)
    Next

End Sub

Private Sub cmd畫圓_Click()
'別忘了是畫在 pic3
    For i = 1 To 40
        X = Int(Rnd * pic3.ScaleWidth)
        Y = Int(Rnd * pic3.ScaleHeight)
        r = Int(Rnd * pic3.ScaleWidth / 5) + 50
        c = Int(Rnd * 5) + 0
        w = Int(Rnd * 3) + 1
        pic3.DrawWidth = w
        pic3.Circle (X, Y), r, QBColor(c), s, e
    Next
End Sub

Private Sub cmd畫線_Click()
'別忘了是畫在 pic2
 For i = 1 To 40
        X = Int(Rnd * pic2.ScaleWidth)
        Y = Int(Rnd * pic2.ScaleHeight)
        z = Int(Rnd * pic2.ScaleWidth)
        j = Int(Rnd * pic2.ScaleHeight)
        c = Int(Rnd * 5) + 0
        w = Int(Rnd * 4) + 1
        pic2.DrawWidth = w
        pic2.Line (z, j)-(X, Y), QBColor(c)
    Next
End Sub

Private Sub pic1_Click()
'清除畫面
    pic1.Cls
End Sub

Private Sub pic2_Click()
'清除畫面
    pic2.Cls
End Sub

Private Sub pic3_Click()
'清除畫面
    pic3.Cls

End Sub

```

```vba=
Private Sub cmd產生果實_Click()
    i = Rnd * pic.ScaleWidth - Me.shp果實.Width
    
    l = Rnd * pic.ScaleHeight - Me.shp果實.Height
    Me.shp果實.Left = i
    Me.shp果實.Top = l
    

End Sub

```
# 影片
https://drive.google.com/drive/folders/1ikXJiNPaAm4qP_hyFsxrunrXiJi5YNC_