473,503 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to display the result of double data type in the decimal places request by user?

19 New Member
i use vb 6.0

this is my work..

Expand|Select|Wrap|Line Numbers
  1.    1.
  2.       Option Explicit
  3.    2.
  4.  
  5.    3.
  6.       Dim Error As Double
  7.    4.
  8.       Dim x As Double
  9.    5.
  10.       Dim y As Double
  11.    6.
  12.       Dim z As Integer
  13.    7.
  14.       Dim eps As Double
  15.    8.
  16.       Dim a As Integer
  17.    9.
  18.       Dim N As Integer
  19.   10.
  20.  
  21.   11.
  22.       Private Sub cmdCalculate_Click()
  23.   12.
  24.  
  25.   13.
  26.       'user input
  27.   14.
  28.  
  29.   15.
  30.       If IsNumeric(txtN) And IsNumeric(txtEps) And IsNumeric(txtX) Then
  31.   16.
  32.       N = txtN.Text
  33.   17.
  34.       a = txtEps.Text
  35.   18.
  36.       x = txtX.Text
  37.   19.
  38.       Else
  39.   20.
  40.           MsgBox "all input must be numeric", vbExclamation, "numeric test"
  41.   21.
  42.           txtN.SetFocus
  43.   22.
  44.       End If
  45.   23.
  46.  
  47.   24.
  48.       'calculate
  49.   25.
  50.  
  51.   26.
  52.       eps = (10 ^ (-a))
  53.   27.
  54.  
  55.   28.
  56.       Do
  57.   29.
  58.           y = x - (x - (N ^ (1 / 3)))
  59.   30.
  60.  
  61.   31.
  62.           Error = Abs(y - x)
  63.   32.
  64.  
  65.   33.
  66.           x = y
  67.   34.
  68.  
  69.   35.
  70.           z = z + 1
  71.   36.
  72.  
  73.   37.
  74.       Loop Until Error < eps
  75.   38.
  76.  
  77.   39.
  78.       'display the result
  79.   40.
  80.       lblDisplay.Caption = "root : " & y & "             iteration : " & z
  81.   41.
  82.  
  83.   42.
  84.       End Sub
  85.   43.
  86.  
  87.   44.
  88.       Private Sub cmdExit_Click()
  89.   45.
  90.       Unload Me
  91.   46.
  92.       End Sub
  93.  
how to make the answer appear in the lable be in the decimal places user wants.. for example,if they put 3 in the txtEps,then the result is something like 0.123..
Mar 2 '08 #1
1 1255
Killer42
8,435 Recognized Expert Expert
Use the Format() function to take a number and return it as a string formatted the way you want. Look up the specifics in your documentation.
Mar 3 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5609
by: Danny Woolston | last post by:
Hi I have a double that i want to round to a certain number of decimal places this is the code i use Return Math.Round(mdNumber, mbDecimalPlaces) mbDecimalPlaces is the number of decimal...
5
1905
by: David Greenwood | last post by:
I posted this under 'microsoft.public.sqlserver.client' but got no reply. Any help with this problem would be greatly appreciated --------------------- I developed a database under SQL Server...
19
6854
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
33
7655
by: Daniel Fadlun | last post by:
Is there a bigger, mathematical, data type in C than the double (64 bit) one or the old long double (80 bit)? I'd like to add precision to my mathematical application, but I can't figure out how....
3
31877
by: android | last post by:
I require a function that takes a double as a parameter and returns the number of decimal places. What is the most efficient way in c# to find out the number of decimal places I have written a...
14
9609
by: cj | last post by:
VB2003. I need a large positive integer. Which is larger int64 or double? I see int64 also apparently is known as long and will hold -9,223,372,036,854,775,808 through...
2
7034
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
5
2041
by: =?Utf-8?B?anVzdGluc2FyYWNlbm8=?= | last post by:
I'm using .net 2.0 and am having a problem adding doubles: double x = 63881.97 + 34297.98; The result of this addition in Visual Studio is 98179.950000000012 This is obviously the incorrect...
2
5076
by: clintonb | last post by:
Victor said: The double value that I'm trying to convert to GCSMoney (which is implemented as cents) was produced by multiplying a dollar amount by an interest rate to get interest. double...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.