vb課程設計小程序
⑴ 用VB設計一個小程序 隨機數
Dim i%, Wei%, a#(1 To 100)
Randomize
For i = 1 To 100
Wei = Int(Rnd * 9 + 1)
Select Case Wei
Case Is = 1
a(i) = Int(Rnd * 10+1)
Case Is = 2
a(i) = Int(Rnd * 100+1)
Case Is = 3
a(i) = Int(Rnd * 1000+1)
Case Is = 4
a(i) = Int(Rnd * 10000+1)
Case Is = 5
a(i) = Int(Rnd * 100000+1)
Case Is = 6
a(i) = Int(Rnd * 1000000+1)
Case Is = 7
a(i) = Int(Rnd * 10000000+1)
Case Is = 8
a(i) = Int(Rnd * 100000000+1)
Case Is = 9
a(i) = Int(Rnd * 1000000000+1)
End Select
Next i
⑵ 用VB設計一個小程序,如圖1所示
就是只加些控制項咯?
⑶ vb小程序設計實例
使用access資料庫,將所有題都事先輸入在題庫中,在軟體運行過程中從題庫中隨即內抽取題目,輸出到容窗體上!
比如試題表Question
可能會有的欄位
欄位 類型 備注
ID int 自增量
Content string 問題描述
Type byte 問題類型,1填空題,2選擇題,3問答題
大概這些,可能根據出的問題不同有更詳細欄位
背景音樂你可以給窗體上放一個windows media player控制項,設置為不可見,然後讓這個控制項放歌就可以了!
⑷ 用vb設計一個小程序要求如圖
樓主你好
我是在VB 6.0的環境下做的
首先設置窗口控制項,我直接上圖
望採納!~謝謝
⑸ 幫忙做簡單《VB程序設計》課程設計
真不知道為什麼書上會讓你們去學Adodc這種垃圾控制項....發布程序的時候帶個累贅不說,用起來也不靈活....
自己用ado寫個多簡單啊....
唉....教育啊.....把些好學生都毀了
⑹ 求VB6.0入門圖文教程 簡單製作一個小程序的
與其說書本,可能還是網上的視頻教程更適合你吧。
可上網搜一下。
⑺ vb課程設計,怎麼做一個小球沿著正弦曲線運動的程序大神來~
改個txt復制後改名為Form1.frm
VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
Caption = "Form1"
ClientHeight = 4545
ClientLeft = 120
ClientTop = 450
ClientWidth = 6465
LinkTopic = "Form1"
ScaleHeight = 303
ScaleMode = 3 'Pixel
ScaleWidth = 431
StartUpPosition = 3 '窗口預設
Begin VB.TextBox TxtFle
Height = 270
Index = 1
Left = 3960
TabIndex = 3
Text = "2"
Top = 2520
Width = 735
End
Begin VB.TextBox TxtFle
Height = 270
Index = 0
Left = 1800
TabIndex = 2
Text = "0"
Top = 2520
Width = 735
End
Begin VB.HScrollBar HScroll1
Height = 375
Left = 2520
Max = 300
TabIndex = 1
Top = 2880
Width = 1335
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 30
Left = 1080
Tag = "0"
Top = 3360
End
Begin VB.CommandButton Command1
Caption = "開始"
Height = 375
Left = 600
TabIndex = 0
Top = 2880
Width = 855
End
Begin VB.Label Label3
Caption = "速度"
Height = 375
Left = 1800
TabIndex = 6
Top = 3000
Width = 615
End
Begin VB.Label Label2
Caption = "最大PI單位"
Height = 255
Left = 2640
TabIndex = 5
Top = 2520
Width = 1095
End
Begin VB.Label Label1
Caption = "最小PI單位"
Height = 255
Left = 600
TabIndex = 4
Top = 2520
Width = 1095
End
Begin VB.Shape Shape1
BackStyle = 1 'Opaque
Height = 255
Left = 2040
Shape = 3 'Circle
Top = 1560
Width = 135
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim SpaceTop As Integer
Dim StepB As Double
Const PI = 3.1415926
Dim SFlag As Boolean
Dim MaxSpeed As Integer
Dim MaxFle As Double
Dim MinFle As Double
Dim Bl As Integer
Private Sub Command1_Click()
If Command1.Caption = "開始" Then
Timer1.Enabled = True
Command1.Caption = "停止"
Else
Timer1.Enabled = False
Command1.Caption = "開始"
End If
End Sub
Private Sub Form_Load()
Bl = 40
SpaceTop = 40
MaxFle = 2 * PI
MinFle = 0
StepB = PI / 100
MaxSpeed = 51
HScroll1.Max = MaxSpeed - 1
HScroll1.Min = 0
HScroll1.Value = 40
Timer1.Interval = MaxSpeed - HScroll1.Value
End Sub
Private Sub HScroll1_Change()
On Error Resume Next
Timer1.Interval = MaxSpeed - HScroll1.Value
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
Me.CurrentX = Timer1.Tag * Bl
Me.CurrentY = SpaceTop + Sin(Timer1.Tag) * Bl
Me.Print "."
If Timer1.Tag <= MaxFle And Timer1.Tag >= MinFle Then
Shape1.Left = Timer1.Tag * Bl - Shape1.Width / 2
Shape1.Top = SpaceTop + Sin(Timer1.Tag) * Bl - Shape1.Width / 2
If SFlag = False Then
Timer1.Tag = Timer1.Tag + StepB
Else
Timer1.Tag = Timer1.Tag - StepB
End If
Else
If SFlag = False Then
SFlag = True
Timer1.Tag = MaxFle
Else
SFlag = False
Timer1.Tag = MinFle
End If
End If
Timer1.Enabled = True
End Sub
Private Sub TxtFle_Change(Index As Integer)
MaxFle = Val(TxtFle(1)) * PI
MinFle = TxtFle(0) * PI
End Sub
其他的自己完善一下吧 下班嘍
⑻ 用VB製作小程序
OptionExplicit
PrivateSubForm_Load()
Randomize
Label1.Caption=Int((Rnd*(999999-100000+1))+100000)'生成100000-999999之間的隨機數
Timer1.Interval=1000'一秒一次
Timer1.Enabled=True
EndSub
PrivateSubTimer1_Timer()
StaticnAsInteger
n=n+1
Ifn=60Then'一秒一次,累加到60此即60秒
n=0
Randomize
Label1.Caption=Int((Rnd*(999999-100000+1))+100000)
EndIf
EndSub
有問題請追問,內滿意請採納,加油!容
⑼ VB設計一個簡單的小程序
變數定義面變數名x,y換別x1y1等
Dim
x1
As
Integer
Private
Sub
Command1_Click()'+按鈕內容
x1
=
x1
+
1
Me.Caption
=
x1
End
Sub
Private
Sub
Command2_Click()'-按鈕
x1=
x1
-
1
Me.Caption
=
x1
End
Sub
⑽ Vb製作小程序
這個不難辦到
你用一個新的模塊將下面的代碼放進去
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32MoleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Private Const PROCESS_QUERY_INFORMATION = 1024
Private Const PROCESS_VM_READ = 16
Private Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Const TH32CS_SNAPPROCESS = &H2
Public Function TestProcIsRunning(ByVal ProcName As String) As Boolean
Dim hFindProc As Long
hFindProc = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
Dim ProcData As PROCESSENTRY32
ProcData.dwSize = Len(ProcData)
Process32First hFindProc, ProcData
While (Process32Next(hFindProc, ProcData) = 1)
Dim sPro As String
sPro = Left(UCase(ProcData.szExeFile), InStr(UCase(ProcData.szExeFile), Chr(0)) - 1)
If sPro = UCase(ProcName) Then
CloseHandle hFindProc
TestProcIsRunning = True
Exit Function
End If
Wend
CloseHandle hFindProc
TestProcIsRunning = False
End Function
然後你用一個timer來實現判斷就可以啦
Private Sub Timer1_Timer()
If TestProcIsRunning("你要判斷的進程名") = True Then
Shell "調用這個程序的路徑", vbHide ''' 你寫雙進程源碼的時候最好要隱藏程序
End If
End Sub
你好,雙進程我也寫過,至於編譯後運行很容易被360攔截掉的,不過用來練手也感覺不錯..