VB脚本怎么写啊?

VB脚本怎么写啊?,第1张

1、Private Sub Command1_Click()

Const msg1 As String="请在这里输入你想显示的一段话!"

Const msg2 As String="这里是对话框要显示的标题."

MsgBox msg1,vbOkOnly,msg2 '此处代码一定不能添加()

End Sub2、 form1按钮点击事件:

form2.show

form1.hide 3、

启动VB程序,在窗体上放置6个命令按钮,三个标签,一个公用对话框、一个进度条、一个状态栏和一个计时器,窗本的布置请参考附图按钮"Open MP3 File"是用来打开对话框选择MP3文件,其他5个按钮分别为Play(播放)、Pause(暂停)、Stopplay(停止播放)、Back(向后跳跃)、Prew(向前跳跃)。Label1用来表示歌曲当前时间;label2放在时度条的最左边,Caption属性为"00:00";lable3放在时度条的右边,用来表示歌曲总长。下面就可以编写代码了。首先在窗体的"通用声明"部分声明函数

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrRetumString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Dim mfn As String

下面就是各个对象的代码了:

Private Sub Form_load()

mfn = ""

play.Enabled = False

pause.Enabled = False

stopplay.Enabled = False

back.Enabled = False

prew.Enabled = False

Timer1.Enabled = False

Timer1.Interval = 500

End Sub

Private Sub open_Click()

On Error GoTo err

With CommonDialog1

.CancelError = True

.Filter = "音乐文件|*.mp3*.wav*.mid"

.Flags = cdlOFNNoChangeDir And cdlOFNPathMustExist

.Action = 1

stopplay_Click '停止按钮同时可以设备初始化

mfn = .FileName '这个程序中文件名一定不能带空格

Form1.Caption = .FileName

play.Enabled = True

End With

play_Click

Exit Sub

err:

End Sub

Private Sub play_Click()

On Error Resume Next

Dim t As Long

t = mciSendString("open " + mfn, 0&, 0, 0) 'Open后边的空格一定不能丢

Dim ret As String * 128

t = mciSendString("status " + mfn + " length", ret, 128, 0)

'显示歌曲总长

ret = Left(ret, 8)

If ret <>"" Then

ProgressBar1.min = 0

ProgressBar1.Max = Val(ret)

Label3.Caption = Gettime(Val(ret))

End If

play.Enabled = False

pause.Enabled = True

stopplay.Enabled = True

back.Enabled = True

prew.Enabled = True

t = mciSendString("status " + mfn + " mode", ret, 128, 0)

'得到设备的当前状态,是播放还是暂停等等

ret = Left(ret, 8)

StatusBar1.Panels(1).Text = ret

'在状态栏显示播放状态

t = mciSendString("play " + mfn + " form " + Str(ProgressBar1.Value), 0&, 0, 0)

'开始播放

Timer1.Enabled = True

End Sub

Private Sub pause_Click()

t% = mciSendString("pause " + mfn, 0&, 0, 0)

'发出暂停的命令

play.Enable = True

pause.Enabled = False

stopplay.Enabled = True

back.Enabled = False

prew.Enabled = False

End Sub

Private Sub stopplay_Click()

t% = mciSendString("stop " + mfn, 0&, 0, 0)

t% = mciSendString("close " + mfn, 0&, 0, 0)

'停止播放

play.Enabled = True

pause.Enabled = False

stopplay.Enabled = False

back.Enabled = False

prew.Enabled = False

End Sub

Private Sub back_Click()

t% = mciSendString("play " + mfn + " from " + Str(ProgressBar1.Value - (ProgressBar1.Max \ 10)), 0&, 0, 0) '向后跳一小段再播放

End Sub

Private Sub prew_Click()

t% = mciSendString("play " + mfn + " from " + Stri(ProgressBar1.Value + (ProgressBar1.Max \ 10)), 0&, 0, 0) '向前跳一小段再播放

End Sub

Private Sub Timer1_Timer()

Dim t As Long

Dim ret As String * 128

t = mciSendString("status " + mfn + " position", ret, 0, 0)

'得到当前播放位置

ret = Left(ret, 8)

ProgressBar1.Value = Val(ret)

Label1.Caption = Gettime(Val(ret))

'显示歌曲当前时间

If ProgressBar1.Value = ProgressBar1.Max Then

stopplay_Click

End If

t = mciSendString("status " + mfn + " mode", ret, 128, 0)

ret = Left(ret, 8)

StatusBar1.Panels(1).Text = ret

End Sub

Private Sub Form_Unload(Cacel As Integer)

t% = mciSendString("stop " + mfn, 0&, 0, 0)

t% = mciSendString("close " + mfn, 0&, 0, 0)

End Sub

Private Function Gettime(position As Long) As String

'这个函数的功能是把以长整型表示的时间转换为电子钟式的"**:**"

Dim min, sec

min = position / 1000

min = min / 60

sec = min - Int(min)

min = Int(min)

sec = 60 * sec / 100

sec = Int(sec * 100)

Gettime = Str(min) + ":" + Str(sec)

End Function

罪犯是C吧。

很好玩的游戏,用脑子想的话就很快的出谁是答案。用编程的话就会墨迹点,因为要表现他们的 *** 作。

VBS或者VB都可以

Dim P(4),X(4)

Dim Rec,Max '记录最大嫌疑者

Dim i

P(0)= "A":X(0)=0'X(0)代表A被怀疑的次数

P(1)= "B":X(1)=0'X(1)代表B被怀疑的次数

P(2)= "C":X(2)=0'X(2)代表C被怀疑的次数

P(3)= "D":X(3)=0'X(3)代表D被怀疑的次数

For i=0 To 3

Select Case P(i)'假设其中一人说了假话,把其余人的推理都验证一遍,在推理过程中被怀疑者加1

Case "A" X(2)=X(2)+1:X(3)=X(3)+1:X(2)=X(2)+1

Case "B" X(0)=X(0):X(3)=X(3)+1:X(2)=X(2)+1

Case "C" X(0)=X(0):X(2)=X(2)+1:X(2)=X(2)+1

Case "D" X(0)=X(0):X(2)=X(2)+1:X(3)=X(3)+1

End Select

Next

Max=X(0):Rec=0

For i=1 To 3

If Max<X(i) Then'查出谁是最大嫌疑者

Max=X(i)

Rec=i

End if

Next

MsgBox "真相只有一个," &P(Rec) &"就是罪犯"

VB脚本就是VBScript,是微软公司推出的网页脚本语言,用于编写网页,VBScript不能独立运行,必须嵌在网页之中,通过浏览器来运行。

而VB是微软公司推出的功能非常强大的编程工具,用于编写各类应用程序。

二者的关系是:VBScript是VB的子集。编网页时用的是VBScript。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12166698.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存