1 / 42

Visual Basic 程式設計

Visual Basic 程式設計. 講師:戴志華 hana@arbor.ee.ntu.edu.tw 國立台灣大學電機工程研究所. 第十章 圖形化使用者介面 III、 滑鼠、鍵盤與安裝程式. ProgressBar. In Microsoft Window Common Controls 6.0 屬性 Min: 最小值 Max: 最大值 Value: 目前進度的值 Scrolling: ccScrollingStandard ccScrollingSmooth. ProgressBar(cont’d). Option Explicit

foster
Download Presentation

Visual Basic 程式設計

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Basic 程式設計 講師:戴志華 hana@arbor.ee.ntu.edu.tw 國立台灣大學電機工程研究所

  2. 第十章 圖形化使用者介面III、滑鼠、鍵盤與安裝程式

  3. ProgressBar • In Microsoft Window Common Controls 6.0 • 屬性 • Min:最小值 • Max:最大值 • Value:目前進度的值 • Scrolling: • ccScrollingStandard • ccScrollingSmooth

  4. ProgressBar(cont’d) Option Explicit Private i As Integer Private Sub Form_Click() i = ProgressBar1.Min Timer1.Interval = 1000 End Sub Private Sub Timer1_Timer() i = i + 1 If (i > ProgressBar1.Max) Then Timer1.Interval = 0 Else ProgressBar1.Value = i End If End Sub 記得要 1.設定Min,Max值 2.加上Timer

  5. Slider

  6. Slider(cont’d)

  7. Slider(cont’d) Label4, 5,6 Label 1,2,3 Shape1

  8. Slider(cont’d) 屬性: Shape1: FillStyle=Solid 屬性 Slider1, 2, 3: Min=0 Max=255 TickFrequency=20 SmallChange=1 LargeChange=10 Private Sub Slider1_Change() Label4.Caption = Slider1.Value Shape1.FillColor = RGB(Slider1.Value, _ Slider2.Value, Slider3.Value) End Sub

  9. Slider(cont’d) Private Sub Slider2_Change() Label5.Caption = Slider2.Value Shape1.FillColor = RGB(Slider1.Value, _ Slider2.Value, Slider3.Value) End Sub Private Sub Slider3_Change() Label6.Caption = Slider3.Value Shape1.FillColor = RGB(Slider1.Value, _ Slider2.Value, Slider3.Value) End Sub 試著將Change改成Scroll

  10. Tabbed Dialog • In Microsoft Tabbed Dialog Control 6.0 • 按右鍵出現屬性對話盒 • Style: • ssStyleTabbedDialog ssStylePropertyPage

  11. Tabbed Dialog(cont’d)

  12. Tabbed Dialog(cont’d) • Orientation:Tab的位置 • ssTabOrientation[Top|Bottom|Left|Right] • TabCaption:Tab上的文字 • Tab Count:Tab的總數 • TabsPerRow:每行有幾個Tabs • 用法類似Frame

  13. 滑鼠

  14. 滑鼠(cont’d)

  15. 滑鼠(cont’d) Private Sub Slider1_Change() Form1.MousePointer = Slider1.Value End Sub

  16. 滑鼠(cont’d) • MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) • Button: 那個鍵被按 • vbRightButton: 2 • vbLeftButton: 1 • vbMiddleButton: 4 • X, Y: 滑鼠的座標值 • Shift: 鍵盤特殊鍵的狀況(Ctrl, Shift, Alt)

  17. 滑鼠(cont’d) • Shift • Shift And vbShiftMask • Shift And vbCtrlMask • Shift And vbAltMask • Ex If (shift and vbshiftmask) then …

  18. Private Sub Form_Click() Print "Click" End Sub Private Sub Form_DblClick() Print "Double Click" End Sub Private Sub Form_MouseDown(……) Print "Mouse Down", Button, If (Shift And vbAltMask) Then Print “Alt”, End If Print End Sub Private Sub Form_MouseUp(……) Print "Mouse Up", Button End Sub 省略

  19. 滑鼠(cont’d) • MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single) • EX: 簡易小畫家

  20. 滑鼠(cont’d) • Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) • CurrentX = X: CurrentY = Y • Select Case Button • Case vbLeftButton • ForeColor = vbBlue • Print "█" • Case vbRightButton • ForeColor = vbRed • Print "█" • Case vbMiddleButton • ForeColor = BackColor • Print "█" • End Select • End Sub

  21. 鍵盤 • KeyDown(KeyCode As Integer, Shift As Integer) • KeyPress(KeyAscii As Integer)

  22. 鍵盤(cont’d) • KeyCode: 鍵盤代碼

  23. 鍵盤(cont’d)

  24. 鍵盤(cont’d) • ←     37     vbKeyLeft • ↑     38     vbKeyUp • →     39     vbKeyRight • ↓     40     vbKeyDown

  25. 鍵盤(cont’d) Private Sub Form_Click() Cls End Sub Private Sub Form_KeyDown(KeyCode As Integer, _ Shift As Integer) Print "Key Down", KeyCode End Sub Private Sub Form_KeyPress(KeyAscii As Integer) Print "Key Press", KeyAscii, Chr(KeyAscii) End Sub Private Sub Form_KeyUp(KeyCode As Integer, _ Shift As Integer) Print "Key Up", KeyCode End Sub

  26. 鍵盤(cont’d)

  27. 自動轉大寫 • Private Sub Text1_KeyPress(KeyAscii As Integer) • If KeyAscii >= Asc("a") and KeyAscii < Asc("z") Then • KeyAscii = Asc(UCase(Chr(KeyAscii))) • End If • End Sub

  28. TextBox只能輸入數字 • Private Sub Text1_KeyPress(KeyAscii As Integer) • If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then • KeyAscii = 0 • End If • End Sub IsNumeric ??

  29. 封裝及部署精靈 • 封裝(Package) 把一些專案用得到的檔案封裝起來 放置封裝目錄 • 部署(Deploy) 將封裝後的檔案複製到使用者可以用來安裝的地方 執行精靈之前須先產生執行檔~~

  30. 封裝及部署精靈(cont’d)

  31. 封裝及部署精靈(cont’d)

  32. 封裝及部署精靈(cont’d) VB不得開啟此專案

  33. 封裝及部署精靈(cont’d)

  34. 封裝及部署精靈(cont’d)

  35. 封裝及部署精靈(cont’d)

  36. 封裝及部署精靈(cont’d)

  37. 封裝及部署精靈(cont’d)

  38. 封裝及部署精靈(cont’d)

  39. 封裝及部署精靈(cont’d)

  40. 封裝及部署精靈(cont’d)

  41. 封裝及部署精靈(cont’d)

  42. 封裝及部署精靈之外 • Setup Toolkit \Wizards\PDWizard\Setup1 • InstallShield http://www.installshield.com

More Related