VBA help for simulation
Private Sub CommandButton1_Click()
'Declare your Variables
Dim InputOne, InPutTwo, InPutThree As Range
Dim OutPutOne, OutPutTwo As Range
'Tell Excel what your Variables are
Set InputOne = Range("C8")
Set InPutTwo = Range("C9")
Set InPutThree = Range("C10")
Set OutPutOne = Range("F10")
Set OutPutTwo = Range("D10")
'Tell Excel What to do in each "if"
If InputOne.Value = "0" And InPutTwo.Value = "0" Then
InPutThree.Value = "0"
ElseIf InputOne.Value = "0" And InPutTwo.Value = "1" Then
InPutThree = "1"
ElseIf InputOne.Value = "0" And InPutTwo.Value = "0" Then
InPutThree.Value = "1"
ElseIf InputOne.Value = "1" And InPutTwo.Value = "0" Then
InPutThree.Value = "0"
End If
If InPutThree.Value = "0" Then
OutPutOne.Value = "UNLATCHED"
OutPutTwo.Value = ""
ElseIf InPutThree.Value = "1" Then
OutPutTwo.Value = "LATCHED"
OutPutOne.Value = ""
End If
End Sub
"Mike B." wrote:
Need help to simulate an electronic card in excel.
A certain card has 2 inputs and 1 output.
Inputs:
C8, C9
Outputs:
C10
At the start, C8 and C9 both have a value of 0. C10 has a value of 0 and
"UNLATCHED" appears in F10.
C9 (has an external link) changes from 0 to 1 when I change some data. This
causes C10 to have a value of 1. "UNLATCHED" disappears from F10 and
"LATCHED" appears in D10.
I change C9 back to 0 when I change the data again. C10 still has a value of
1. "LATCHED" remains in D10.
I created a button that changes C8 from 0 to 1 and vice versa. When I press
the button, C8 becomes a 1.
I want C10 to become 0. "LATCHED" disappears from F10 and "UNLATCHED"
appears in F10. After 2 seconds, C8 becomes a 0 and we are back at square 1.
Maybe this will help:
C8 C9 C10 D10 F10
1. 0 0 0 0
"UNLATCHED"
2. 0 1 1 "LATCHED"
3. 0 0 1 "LATCHED"
4. 1 0 0
"UNLATCHED"
5. back to square 1
Thanks in advance
|