Solved

How to use round() correctly

Posted on 1998-08-23
8
159 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 …
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…
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…

739 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