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

x
?
Solved

How to use round() correctly

Posted on 1998-08-23
8
Medium Priority
?
161 Views
Last Modified: 2010-04-30
I´v problems using round() in my VB4.0:
When I use x=round(5,34) then the compiler says:" Wrong
amount of arugment..."
Do I need to load a Math-Liabrary or s.th.
Please answer with a working example!!!
0
Comment
Question by:qwertzu
[X]
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
  • 4
  • 2
  • 2
8 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1430559
Can't you use

x = Round(34)

???

Regards,
Viktor Ivanov

0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1430560
What are you trying to do , what are the numbers 5,34?
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1430561
If you ask for mod coze you have 2 numbers here is your answer:

This example uses the Mod operator to divide two numbers and return only the remainder. If either number is a floating-point number, it is first rounded to an integer.

Dim MyResult
MyResult = 10 Mod 5      ' Returns 0.
MyResult = 10 Mod 3      ' Returns 1.
MyResult = 12 Mod 4.3      ' Returns 0.
MyResult = 12.6 Mod 5      ' Returns 3.

If you trying something else let us know.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:viktornet
ID: 1430562
If you are trying to round a number to an integer then use this

Int(34.45)

Regards,
Viktor Ivanov
0
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1430563
qwertzu,
Round is a vb function, does not require any other lib.

Dim x as Integer

x= round(5.34) ' return 5
x= round(5.57)  ' return 6.

Your code looked like x= round(5,34). I think that is the problem. You can only pass one number to this function.

Regards
Dalin
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430564
Ain't the answer same as my suggestion??? =|

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430565
Even though I'm not a VB programmer, I think there is no such function as Round in VB...
Correct me if I'm wrong...What I mean a function that is called Round....Int() function rounds off the float number to an integer =)

Regards,
Viktor Ivanov
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1430566
Hi, all,
I think viktornet is right. Round may not be a VB function. I have used it before but I had crystal report. I try to look for it but I do not have VB4 anymore.

I am sorry if I misled any of you, and I appologize for my mistake.

Qwertzu, it looked like you have the function based on the error message you have, If you don't have the function, you should get an error message saying "function not defined" or somrthing like that, rather than wrong number of argument. You can search the On-line help in your VB IDE.

Regards to all.
Dalin



0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

730 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