Solved

How to use round() correctly

Posted on 1998-08-23
8
160 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 50 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month4 days, left to enroll

630 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