|
-
Oct 5th, 2000, 10:55 AM
#1
Thread Starter
Hyperactive Member
Divide, 2/11....... after i get the answer 5.5 how would i get the 5 after the .?
-RaY
VB .Net 2010 (Ultimate)
-
Oct 5th, 2000, 11:21 AM
#2
_______
<?>
Code:
'there must be a math function for this but I don't have
'msdn available and you are using VB3 so I don't even know
'if you have access to the InStr/cSng Functions.
Private Sub Form_Load()
'I assume there are better ways but this will work
'if using decimals you must be using single/double/long
'x = result of your division
Dim x As Single
x = 5.5
Dim SearchString, SearchChar, MyPos
'convert it to a string
SearchString = CStr(x)
'search for the .
SearchChar = "."
MyPos = InStr(1, SearchString, SearchChar, 1)
'if found MyPos will be > 0
If MyPos > 0 Then
'trim away all but what follows the .
SearchString = Right(SearchString, Len(SearchString) - MyPos)
'switch back to single
x = CSng(SearchString)
MsgBox x 'value of x as a single
End If
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 5th, 2000, 12:12 PM
#3
Lively Member
Not sure if this works for everything, but you can try it out:
Code:
Dim x As Single
x = (11 / 2 - 11 \ 2)
MsgBox (x)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|