请教,有个VB编程问题(求助)
各位论坛的友友们,你们好,想请教各位一个问题,是关于编程的问题如下:
以下是一段关于声音控制的一段代码,现要做如下改进:
编程软件可以随机控制多个扬声器一起发声,随机控制线路增加灵活性(就是页面上参数的灵活性)
Option Explicit
Dim m_timers As Long
Dim m_curTimers As Long
Dim m_curIndex As Integer '记录当前打开的继电器
Dim m_n As Long '记录循环次数
Private Sub Check1_Click(Index As Integer)
OutData
End Sub
Sub OutData()
Dim SendByte As Integer
Dim Bit_Wert As Integer
SendByte = 0
Dim x As Integer
For x = 1 To 8
If Check1(x).Value = 1 Then
SendByte = SendByte + Mark(x - 1)
End If
Next
Debug.Print SendByte
Out DataRegister, SendByte 'Data lines (data bus)
End Sub
Private Sub CmdStart_Click()
If CmdStart.Caption = "开始" Then
Timer1.Interval = Val(TxtOpenTime.Text)
If Timer1.Interval = 0 Then
MsgBox "打开时间不能为0"
Exit Sub
End If
m_timers = Val(txtCloseTime.Text) * 1000 / Timer1.Interval
Timer1.Enabled = True
m_curTimers = 0
CmdStart.Caption = "停止"
TxtOpenTime.Enabled = False
txtCloseTime.Enabled = False
TxtTimes.Enabled = False
m_n = 0
Else
Out DataRegister, 0
CmdStart.Caption = "开始"
TxtOpenTime.Enabled = True
txtCloseTime.Enabled = True
TxtTimes.Enabled = True
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Mark(0) = &H1
Mark(1) = &H2
Mark(2) = &H4
Mark(3) = &H8
Mark(4) = &H10
Mark(5) = &H20
Mark(6) = &H40
Mark(7) = &H80
TxtOpenTime.Text = "40"
txtCloseTime.Text = "5"
TxtTimes.Text = "100"
TxtInfo.Text = ""
Dim i As Integer
For i = 1 To 8
Check1(i).Caption = "线路" + Trim(i)
Next
Timer1.Enabled = False
Option1(0).Value = True
'Option1_Click 0
End Sub
Function RndOpen() As Integer
Dim i As Integer
RndOpen = Rnd() * 7
RndOpen = Rnd() * 7
End Function
Private Sub Option1_Click(Index As Integer)
Frame1(Index).Enabled = True
Frame1(1 - Index).Enabled = False
End Sub
Private Sub Timer1_Timer()
If m_curTimers = 0 Then
Dim rndIndex As Integer
rndIndex = RndOpen
While rndIndex = m_curIndex
rndIndex = RndOpen
Wend
m_curIndex = rndIndex
Out DataRegister, Mark(m_curIndex)
m_curTimers = m_curTimers + 1
TxtInfo.Text = TxtInfo.Text + vbCrLf + "打开线路" + Str(m_curIndex + 1)
Else
If m_curTimers = 1 Then
TxtInfo.Text = TxtInfo.Text + vbCrLf + "关闭线路" + Str(m_curIndex + 1)
TxtInfo.SelLength = 0
TxtInfo.SelStart = Len(TxtInfo.Text)
End If
Out DataRegister, 0
m_curTimers = m_curTimers + 1
End If
If m_curTimers = m_timers Then
m_n = m_n + 1
m_curTimers = 0
End If
If m_n >= Val(TxtTimes.Text) Then
CmdStart_Click
End If
End Sub
现在这个代码,放在那个应用软件包里只能控制单个扬声器发声,要对其做些改进,使其可以随机控制多个扬声器一起发声,随机控制线路增加灵活性(就是页面上参数的灵活性)
整个问题就是这样,希望各位看到的高手帮个忙,谢谢了 --------------------编程问答-------------------- 刚才我回贴这么被删除了
这个代码这么控制声音的
我没有看出来啊
用控件了? --------------------编程问答-------------------- 我是计算机专业的学生,大一的,但是学的是C,没学过VB,这段代码是一个中医药大学的老乡要写的关于声音定位系统的一个软件里的代码,他只会如何使用那个软件,不会编程,现在需要按要求来改进那个软件
他就向我求助,我就上论坛来发帖,看看有没有高手来帮帮忙
补充:VB , 基础类