| | |
binary counter
![]() |
•
•
Join Date: Oct 2005
Posts: 5
Reputation:
Solved Threads: 0
sure, the idea is is that I got a textbox (txtNumber). a label(lblBinary)
As you may know the binary siystem consists of to digits 1 and 0
now, what I want is for the number 5 for example, to change into binary code when I use a command button
The conde regarding the button could look something like this:
lblBinary.caption=val(txtNumber)^2
This code only doubles the number inserted. It does not produce the binary code for that number.
How do I pull this off?
Help needed
As you may know the binary siystem consists of to digits 1 and 0
now, what I want is for the number 5 for example, to change into binary code when I use a command button
The conde regarding the button could look something like this:
lblBinary.caption=val(txtNumber)^2
This code only doubles the number inserted. It does not produce the binary code for that number.
How do I pull this off?
Help needed
•
•
•
•
Originally Posted by w00dy
Hello, and welcome.
Can you give us a little more information on what you're trying to do?
In this code I write 2 functions, one function convert from char to binary and another one is for convert from string to binary code.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub Form_Load() MsgBox (char2bin("a")) MsgBox (txt2bin("Hello World")) End Sub Function txt2bin(str2bin As String) As String Dim result As String For i = 1 To Len(str2bin) result = result & char2bin(Mid(str2bin, i, 1)) Next i txt2bin = result End Function Function char2bin(chr2bin As String) As String Dim result As String Dim char2asc As Integer, total As Integer char2asc = Asc(chr2bin) For i = 7 To 0 Step -1 If char2asc >= (total + (2 ^ i)) Then total = total + (2 ^ i) result = result & "1" Else result = result & "0" End If Next i char2bin = result End Function
![]() |
Similar Threads
- Binary File IO (C#)
- PIC Basic programming with RF modules (Assembly)
- Help me. binary seach tree (C)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Stopping a timer
- Next Thread: Error message when using database chart wizard
Views: 3977 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex ado array basic beep beginner blackjack bmp box c++ calculator cells.find channel9 click component connection creative data database datareport date delete desktop dissertationtopic edit error excel excelmacro file filename filter flex form hardware icon ide image installer interaction key keypress label liveperson looping mail match messagebox microsoft number object open oracle password pause pdf picture pos print programmer prompt query random range range-objects readfile reading record refresh remotesqlserverdatabase report reports retrieve save search sites sort spectateswamp sql sql2008 sqlserver struct sum table tags timer variable vb vb6 vb6.0 vba vista visual visualbasic web windows





