Forum Webscript.Ru
Разное => Флейм => Тема начата: alex007 от 31 Января 2003, 14:06:52
-
Люди помогите со скриптом на vb:
\'General Declarations
Const RED = &HFF&
Const LIGHTBLUE = &HFFFF00
Const GREEN = &HFF00&
Const BLUE = &HFF0000
Const PINK = &HFF00FF
Dim LightState, CountNumber As Integer
Dim LoopNumber As String
Private Sub Form_Load()
LoopNumber = 0
CountNumber = 0
End Sub
Private Sub tmrLight_Timer()
Select Case LightState
Case LightState = 0
shpLight(0).FillColor = RED
shpLight(1).FillColor = BLUE
shpLight(2).FillColor = GREEN
shpLight(3).FillColor = LIGHTBLUE
shpLight(4).FillColor = PINK
tmrLight.Interval = 3000
LightState = 1
Case LightState = 1
shpLight(0).FillColor = PINK
shpLight(1).FillColor = RED
shpLight(2).FillColor = BLUE
shpLight(3).FillColor = GREEN
shpLight(4).FillColor = LIGHTBLUE
tmrLight.Interval = 3000
LightState = 2
Case LightState = 2
shpLight(0).FillColor = LIGHTBLUE
shpLight(1).FillColor = PINK
shpLight(2).FillColor = RED
shpLight(3).FillColor = BLUE
shpLight(4).FillColor = GREEN
tmrLight.Interval = 3000
LightState = 3
Case LightState = 3
shpLight(0).FillColor = GREEN
shpLight(1).FillColor = LIGHTBLUE
shpLight(2).FillColor = PINK
shpLight(3).FillColor = RED
shpLight(4).FillColor = BLUE
tmrLight.Interval = 3000
LightState = 4
Case LightState = 4
shpLight(0).FillColor = BLUE
shpLight(1).FillColor = GREEN
shpLight(2).FillColor = LIGHTBLUE
shpLight(3).FillColor = PINK
shpLight(4).FillColor = RED
tmrLight.Interval = 3000
LightState = 0
End Select
\'adding 1 to CountNumber
CountNumber = CountNumber + 1
\'checking if CountNumber is equal to the value in the LoopNumber string.
If CountNumber = LoopNumber Then
\'setting the Enabled property of the timer control to False
tmrLight.Enabled = False
\'setting the Text property of the txtCount text box control to the string value of
\'CountNumber
txtCount.Text = CountNumber
End If
End Sub
Private Sub txtPassword_Change()
Dim i As Integer
If txtPassword = "test" Then
\'change the BackColor of txtPassword to green
txtPassword.BackColor = GREEN
\'Refresh method to update the colour immediately
frmDisco.Refresh
\'set the Visible property of the txtPassword text box control to False
txtPassword.Visible = False
\'by using an InputBox$ function to output a prompt and obtain a string from the user
sString = InputBox$("Please enter the value specifies how many complete rotations of the colours will be executed")
\'placign the string in the variable LoopNumber
LoopNumber = sString
\'set the Visible property of each shape control to True
For i = 0 To 4
shpLight(i).Visible = True
Next
\'set the tmrLight Enabled property to True
tmrLight.Enabled = True
\'call the tmrLight_Timer sub procedure
Call tmrLight_Timer
End If
End Sub
Проблема выделена жирным, тоесть доходит до второго case и не сменивает цвет.
С условием не меня код.
Жду ответов.
С Уважением,
Алекс.
-
Так что ни кто не знает VB????
Подскажите ссылки на веб сайты где VBшники сидят.
-
Select Case LightState
Case LightState = 0
по-моему правельно будет
Select Case LightState
Case 0
и т.д.
-
xnx
Спасибо, теперь работает.
Просто я писал это дело по экз. документу где было написано так:
LightState = 0
shpLight(0) set FillColor to RED
shpLight(1) set FillColor to BLUE
shpLight(2) set FillColor to GREEN
shpLight(3) set FillColor to LIGHTBLUE
shpLight(4) set FillColor to PINK
set the Interval property of the timer control to hold the colours for 3 seconds
set LightState to 1
Вот я и использовал так как было написано в экз. доке
-
alex007
А надо было найти мануал по VBScript %)
-
Xander
Да она у меня есть, просто сказали что бы не фига не меняли код, а делали то что было написано на экзамеционой бумаге, хотя я лично нашел 2 ошибки.