Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dividing a number of two figures over two variables

Status
Not open for further replies.

bvdv

Programmer
May 20, 2001
4
NL
Is it possible to divide a number which contains two figures over two variables.

So par example if A= 14, then B sould be 1 and C should be 4.
And if A = 59, then B should be 5 and C should be 9.

I hope someone knows the command for this.Is it possible to divide a number which contains two figures over two variables.

So par example if A= 14, then B sould be 1 and C should be 4.
And if A = 59, then B should be 5 and C should be 9.

I hope someone knows the command for this.Is it possible to divide a number which contains two figures over two variables.

So par example if A= 14, then B sould be 1 and C should be 4.
And if A = 59, then B should be 5 and C should be 9.

I hope someone knows the command for this.
 
B = left$(A,1)
C = right$(A,1)

or

B = mid$(A,1,1)
C = mid$(A,2,1)
David Paulson


 
The general case
Code:
Dim lngDigits() as long
lngDigits = GetDigits(59,2)
'===========
Function GetDigits(byval lngIn as long, byval lngNo) as long()
    dim lngW() as long
    dim lngNext as long
    lngNext = lngIn
    Redim lngW(lngNo)
    ' Subscript 0 Unused
    For I = Ubound(intW) to 1 Step-1   ' Reverse Order
        intW(I) =  lngNext mod 256 ' Remainder after divide
        lngNext = lngNext \ 256        ' integer division
    Next
    GetDigits = lngW
End Funtion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top