Solved

How to use round() correctly

Posted on 1998-08-23
8
155 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
  • 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
 
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now