| | |
binary counter
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
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: 3782 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





