Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Read binary digits into memory

Posted on 1999-07-26
Medium Priority
Last Modified: 2010-04-30
I previously (under a different name) how to read the binary digits from a file and write them to a ascii text file in either binary or hex, but now i am wondering if there is a way to read them into an integer in memory as a decimal number.
Question by:theoracle
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 18

Accepted Solution

deighton earned 140 total points
ID: 1527658
Use the following function to change base 2 to base 10

  Dim iInt As Integer

  iInt = Val(nTOm(Text5, 2, 10))

Private Function nTOm(sX As String, n As Integer, m As Integer)

    'works for number bases 2 to 16
    Dim lNumber As Long
    Dim c As Integer
    Dim sAtom As String
    Dim lVal As Long
    Dim x As Long
    For c = Len(sX) To 1 Step -1
        sAtom = UCase(Mid(sX, c, 1))
        If n > 10 Then
            If sAtom >= "A" And sAtom <= "F" Then
                lVal = Asc(sAtom) - Asc("A") + 10
                lVal = CLng(sAtom)
            End If
            lVal = CLng(sAtom)
        End If
        lNumber = lNumber + lVal * n ^ x
        x = x + 1
    nTOm = ""
    While lNumber > 0
        x = lNumber Mod m
        If x < 10 Then
            sAtom = CStr(x)
            sAtom = Chr(Asc("A") + x - 10)
        End If
        nTOm = sAtom + nTOm
        lNumber = lNumber \ m
    If nTOm = "" Then nTOm = "0"
End Function


Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question