`replacing the value of 0 and 1 to t and f
this is the code wriiten in the form ..........
Code:
Private Sub cmdAdd_Click()
If LenB(cboInputs) Then
cboInputs.AddItem Chr(65 + cboInputs.ListCount) & ": " & cboInputs.Text
End If
End Sub
Private Sub cmdClear_Click()
cboInputs.Clear
lstTruthTable.Clear
txtOutput = vbNullString
End Sub
Private Sub cmdDraw_Click()
Dim i As Integer
Dim l As Long
For i = cboInputs.ListCount - 1 To 0 Step -1
Next
lstTruthTable.Clear
For l = 0 To (2 ^ cboInputs.ListCount) - 1
lstTruthTable.AddItem DecToBinary(l, cboInputs.ListCount)
Next
End Sub
this is the code of the module.....
Code:
Option Explicit
Function TruthTableAND(Inputs() As Boolean, Outputs() As Integer) As Boolean
Dim i As Integer
Dim l As Long
For i = 0 To UBound(Inputs)
If Inputs(i) Then l = l + (2 ^ i)
Next
For i = 0 To UBound(Outputs)
If Outputs(i) = l Then
TruthTableAND = True
Exit Function
End If
Next
End Function
'if a+b+c+d
Function TruthTableOR(Inputs() As Boolean, Outputs() As Integer) As Boolean
End Function
Function DecToBinary(Dec As Long, Places As Integer) As String
Dim d As Long
Dim strResult As String
Dim intPlaces As Integer
d = Dec
Do Until d = 0
If d Mod 2 Then
strResult = "1" & strResult
d = (d - 1) / 2
Else
strResult = "0" & strResult
d = d / 2
End If
Loop
intPlaces = Places - Len(strResult)
If intPlaces > 0 Then strResult = Replace(Space(intPlaces) & strResult, " ", 0)
DecToBinary = strResult
Debug.Print strResult
End Function
please help me replace the output to t and f plzzz..tnks in advnce..
http://http://img84.imageshack.us/im...agawegtvz1.jpg
Re: `replacing the value of 0 and 1 to t and f
Before the last line Debug.Print add this code:
Code:
strResult = Replace$(strResult,"0","f")
strResult = Replace$(strResult,"1","t")
Debug.Print strResult