Results 1 to 5 of 5

Thread: Binary conversion

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    81

    Post

    is there a fuction to convert a number to binary if not how do i do it...

    thanks

    brooke

  2. #2
    Junior Member
    Join Date
    Jun 1999
    Location
    St. Louis MO USA
    Posts
    18

    Post

    Try this:
    Dim xint as integer
    dim StrString as string
    xint = any integer
    do until xint <= 0
    if raminder(xint,2) > 0 then
    StrString = '1' & StrString
    xint = (xint-1)/2
    else
    StrString = '0' & StrString
    xint = xint/2
    end if
    loop
    StrSting = binary number

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Posts
    81

    Post

    It doesn't work...

  4. #4
    Addicted Member
    Join Date
    Jan 1999
    Posts
    239

    Post

    Take a look at this article, it has exactly
    what you are looking for.

    http://www.vb-world.net/misc/addins/


  5. #5
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Gloucestershire, England
    Posts
    301

    Post

    Try this

    Public Function Bin_conv(Byval value as long) as string

    Dim multi As Long
    Dim binary As Variant

    multi = 0
    binary = 0

    If value > 2048 Then
    msgbox = "**Overflow**"
    Exit Function
    End If
    Do While (value > 0)
    remainder = value Mod 2
    value = Fix(value / 2)
    If remainder = 1 Then binary = binary + 10 ^ multi
    multi = multi + 1
    Loop
    Bin_conv = binary
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width