當前位置:編程學習大全網 - 源碼破解 - VB程序怎麽做出以下這些工程 給出步奏

VB程序怎麽做出以下這些工程 給出步奏

三個滾動條設置:min:0;max:255;smallchange:5;largechange:20

text1---text3用來顯示妳所選擇單原色,並在相應的label中顯示出數值。

Text4用來顯示混合以後的顏色。

第二步:編寫程序代碼如下:

Private Sub VScroll1_Change()

Label1.Caption = "紅色:" Str(VScroll1.Value)

Text1.BackColor = RGB(VScroll1.Value, 0, 0)

Text4.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)

End Sub

Private Sub VScroll2_Change()

Label2.Caption = "綠色:" Str(VScroll2.Value)

Text2.BackColor = RGB(0, VScroll2.Value, 0)

Text4.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)

End Sub

Private Sub VScroll3_Change()

Label3.Caption = "蘭色:" Str(VScroll3.Value)

Text3.BackColor = RGB(0, 0, VScroll3.Value)

Text4.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)

End Sub

這是調色器 界面自己設計啊

Private Sub Form_Load()

Me.ScaleMode = 3

Me.AutoRedraw = True

If Me.Width < 3000 Then Me.Width = 3000

If Me.Height < 3000 Then Me.Height = 3000

End Sub

Private Sub Init()

Dim i As Integer

BaseX = Me.ScaleWidth / 2

BaseY = Me.ScaleHeight / 2

R = IIf(BaseX > BaseY, BaseY * 0.8, BaseY * 0.8)

r1 = R * 0.2

r2 = R * 0.1

r3 = R * 0.05

For i = 0 To 360 Step 6

If i Mod 30 = 0 Then'時

Me.DrawWidth = 2

DrawLine BaseX (R - 3) * Sin(i * PI / 180), BaseY - (R - 3) * Cos(i * PI / 180), BaseX (R - 8) * Sin(i * PI / 180), BaseY - (R - 8) * Cos(i * PI / 180), 3

Else'分

Me.DrawWidth = 2

Me.PSet (BaseX (R - 3) * Sin(i * PI / 180), BaseY - (R - 3) * Cos(i * PI / 180))

End If

Next

Me.DrawWidth = 1

Me.Circle (BaseX, BaseY), R

End Sub

'繪制指針

Private Sub DrawClock()

Dim Second As Integer

Dim Minute As Integer

Dim Hours As Integer

Second = DatePart("s", Time)

Minute = DatePart("n", Time)

Hours = DatePart("h", Time)

If Hours > 12 Then

Hours = Hours - 12

End If

Me.DrawWidth = 1

Me.Circle (BaseX, BaseY), 4

DrawLine BaseX - r1 * Sin(Second * PI / 30), BaseY r1 * Cos(Second * PI / 30), BaseX (R - 10) * Sin(Second * PI / 30), BaseY - (R - 10) * Cos(Second * PI / 30), 0

DrawLine BaseX - r2 * Sin(Minute * PI / 30), BaseY r2 * Cos(Minute * PI / 30), BaseX R * 0.8 * Sin(Minute * PI / 30), BaseY - R * 0.8 * Cos(Minute * PI / 30), 1

DrawLine BaseX - r3 * Sin((Hours Minute / 60) * PI / 6), BaseY r3 * Cos((Hours Minute / 60) * PI / 6), BaseX R * 0.6 * Sin((Hours Minute / 60) * PI / 6), BaseY - R * 0.6 * Cos((Hours Minute / 60) * PI / 6), 2

End Sub

'畫線函數

Private Sub DrawLine(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, Flag As Integer)

Static OldSX1 As Integer, OldSX2 As Integer, OldSY1 As Integer, OldSY2 As Integer

Static OldMX1 As Integer, OldMX2 As Integer, OldMY1 As Integer, OldMY2 As Integer

Static OldHX1 As Integer, OldHX2 As Integer, OldHY1 As Integer, OldHY2 As Integer

Select Case Flag

Case 0

Me.DrawWidth = 1

Me.Line (OldSX1, OldSY1)-(OldSX2, OldSY2), Me.BackColor

Me.Line (x1, y1)-(x2, y2)

OldSX1 = x1

OldSX2 = x2

OldSY1 = y1

OldSY2 = y2

Case 1

Me.DrawWidth = 2

Me.Line (OldMX1, OldMY1)-(OldMX2, OldMY2), Me.BackColor

Me.Line (x1, y1)-(x2, y2)

OldMX1 = x1

OldMX2 = x2

OldMY1 = y1

OldMY2 = y2

Case 2

Me.DrawWidth = 3

Me.Line (OldHX1, OldHY1)-(OldHX2, OldHY2), Me.BackColor

Me.Line (x1, y1)-(x2, y2)

OldHX1 = x1

OldHX2 = x2

OldHY1 = y1

OldHY2 = y2

Case Else

Me.Line (x1, y1)-(x2, y2)

End Select

End Sub

Private Sub Form_Resize()

Me.Cls

Call Init

End Sub

Private Sub Timer1_Timer()

Call DrawClock

End Sub

這是時鐘程序 ,功能比較多!

步驟壹:繪制界面。

新建壹個標準EXE工程,將其Caption屬性改為“超級記事本”,點擊Icon屬性給它找個合適的Icon圖標。單擊菜單“工程”-“部件”,在彈出的“部件”對話框裏找到Microsoft RichText Box 6.0和公***對話框Microsoft Common Dialog 6.0並選中它們,單擊“確定”按鈕。這時左邊的工具欄上出現了我們剛才新添的兩個控件了。在窗體上繪制RichText Box和Commn Dialog,其中RichText Box的大小和位置可不用理睬,我們將在代碼中處理它,當然,有必要把它的ScrollBar屬性設為2-rtfVertical,這樣在打開和編輯文件時垂直滾動條才可用。

步驟二:編輯菜單。

按Ctrl E調出菜單編輯器,我們來做如下幾個菜單:

壹.文件菜單:

文件(第壹層) mnuFile

新建(第二層) mnuNew

打開(第二層) mnuOpen

保存(第二層) mnuSave

- (第二層) mnuFileSep (分隔線)

退出(第二層) mnuExit

二.編輯菜單:

編輯(第壹層) mnuEdit

復制(第二層) mnuCopy

剪切(第二層) mnuCut

粘貼(第二層) mnuPaste

- (第二層) mnuEditSep (分隔線)

全選(第二層) mnuSelecAll

三.搜索菜單:

搜索(第壹層) mnuSearch

查找(第二層) mnuFind

查找下壹個(第二層) mnuFindOn

四.幫助菜單:

幫助(第壹層) mnuHelp

使用說明(第二層) mnuUsage

關於(第二層) mnuAbout

(註:各菜單項的快捷鍵請自行設置)

好了,其它的菜單項以後再根據需要添加。現在進入:

步驟三:編寫代碼。

'聲明查找變量

Dim sFind As String

'聲明文件類型

Dim FileType, FiType As String

'初始化程序

Private Sub Form_Load()

'設置程序啟動時的大小

Me.Height = 6000

Me.Width = 9000

End Sub

'設置編輯框的位置和大小

Private Sub Form_Resize()

On Error Resume Next '出錯處理

RichTextBox1.Top=20

RichTextBox1.Left=20

RichTextBox1.Height = ScaleHeight-40

RichTextBox1.Width = ScaleWidth-40

End Sub

'新建文件

Private Sub mnuNew_Click()

RichTextBox1.Text = "" '清空文本框

FileName = "未命名"

Me.Caption = FileName

End Sub

'打開文件

Private Sub mnuOpen_Click()

CommonDialog1.Filter = "文本文檔(*.txt)|*.txt|RTF文檔(*.rtf)|*.rtf|所有文件(*.*)|*.*"

CommonDialog1.ShowOpen

RichTextBox1.Text = "" '清空文本框

FileName = CommonDialog1.FileName

RichTextBox1.LoadFile FileName

Me.Caption = "超級記事本:" & FileName

End Sub

'保存文件

Private Sub mnuSave_Click()

CommonDialog1.Filter = "文本文檔(*.txt)|*.txt|RTF文檔(*.rtf)|*.rtf|所有文件(*.*)|*.*"

CommonDialog1.ShowSave

FileType = CommonDialog1.FileTitle

FiType = LCase(Right(FileType, 3))

FileName = CommonDialog1.FileName

Select Case FiType

Case "txt"

RichTextBox1.SaveFile FileName, rtfText

Case "rtf"

RichTextBox1.SaveFile FileName, rtfRTF

Case "*.*"

RichTextBox1.SaveFile FileName

End Select

Me.Caption = "超級記事本:" & FileName

End Sub

'退出

Private Sub mnuExit_Click()

End

End Sub

'復制

Private Sub mnuCopy_Click()

Clipboard.Clear

Clipboard.SetText RichTextBox1.SelText

End Sub

'剪切

Private Sub mnuCut_Click()

Clipboard.Clear

Clipboard.SetText RichTextBox1.SelText

RichTextBox1.SelText = ""

End Sub

'全選

Private Sub mnuSelectAll_Click()

RichTextBox1.SelStart = 0

RichTextBox1.SelLength = Len(RichTextBox1.Text)

End Sub

'粘貼

Private Sub mnuPaste_Click()

RichTextBox1.SelText = Clipboard.GetText

End Sub

'查找

Private Sub mnuFind_Click()

sFind = InputBox("請輸入要查找的字、詞:", "查找內容", sFind)

RichTextBox1.Find sFind

End Sub

'繼續查找

Private Sub mnuFindOn_Click()

RichTextBox1.SelStart = RichTextBox1.SelStart RichTextBox1.SelLength 1

RichTextBox1.Find sFind, , Len(RichTextBox1)

End Sub

'使用說明

Private Sub mnuReadme_Click()

On Error GoTo handler

RichTextBox1.LoadFile "Readme.txt", rtfText '請寫好Readme.txt文件並存入程序所在文件夾中

Me.Caption = "超級記事本:" & "使用說明"

Exit Sub

handler:

MsgBox "使用說明文檔可能已經被移除,請與作者聯系。", vbOKOnly, " 錯誤信息"

End Sub

'關於

Private Sub mnuAbout_Click()

MsgBox "超級記事本 Ver1.0 版權所有(C) 2001 土人",vbOKOnly,"關於"

End Sub

'設置彈出式菜單(即在編輯框中單擊鼠標右鍵時彈出的動態菜單)

Private Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 2 Then

Popu

這是編輯器

第壹個就用comamand1.top=comamand1.top+15 即可使它向上運動拉

  • 上一篇:捷克囚徒中的女主角Tatiana Vilhelmová 的詳細資料
  • 下一篇:紅客是什麽?紅客是跟黑客相反的麽?
  • copyright 2024編程學習大全網