Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB Substr

Posted on 2009-07-12
1
Medium Priority
?
860 Views
Last Modified: 2012-05-07
hi there,

may i know how to get 2 decimal number in Visual Basic.
I don't want to use round() function

Example.

12.34555 = 12.34
12.37555 = 12.37 not 12.38
12.36222 = 12.36
1.3622 = 1.36
1.3688 = 1.36

Please help me.
0
Comment
Question by:junaidahhalim
1 Comment
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 24836995
You could try this, assuming that MyVariable is declared as Single or Double:

MyVariable = Int(MyVariable * 100) / 100
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

886 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