473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

"double" population

When i try to populate a dropdownlist menu, using a for cicle works
perfect: i get a list of int from ie 1 to 10. How an populate my
ddlist if working on the code i wish to get not longer a series of
integers, but a series of decimals?

Like this:
old fashion: (for i=1; i<=100; i++) i get 100 integers;

New fashion) i want to populate the same list, but using the decimals:
1; 1.01; 1.02; 1.03.... 99.99, 100.00

Is it possible?

Any suggestion?

Sep 25 '07 #1
4 1493
vinnie wrote:
When i try to populate a dropdownlist menu, using a for cicle works
perfect: i get a list of int from ie 1 to 10. How an populate my
ddlist if working on the code i wish to get not longer a series of
integers, but a series of decimals?

Like this:
old fashion: (for i=1; i<=100; i++) i get 100 integers;

New fashion) i want to populate the same list, but using the decimals:
1; 1.01; 1.02; 1.03.... 99.99, 100.00
That's a lot of items. :)
Is it possible?
Anything is possible. :)

In your specific example, you appear to be incrementing your counter by
hundredths. So, you might use a loop like this:

for (decimal num = 1.0; num <= 100.0; num += 0.01)
{
// code to add to list here
}

You could also use floats, but I think the decimal type might work
better for your situation.

For that matter, you could use an integer, going from 100 to 10000,
where you divide by 100 when adding the value to the list.

Pete
Sep 25 '07 #2
vinnie,

You can always use the decimal type, like so:

for (decimal index = 1M; index <= 100M; ++index)
{
// Do something with the decimal here.
}

The for loop is not limited to numbers, it can be anything, the idea is
that it is in three parts. The first is the variable initializers, the
second is the check, and the third is the code that changes the state.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"vinnie" <ce**********@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
When i try to populate a dropdownlist menu, using a for cicle works
perfect: i get a list of int from ie 1 to 10. How an populate my
ddlist if working on the code i wish to get not longer a series of
integers, but a series of decimals?

Like this:
old fashion: (for i=1; i<=100; i++) i get 100 integers;

New fashion) i want to populate the same list, but using the decimals:
1; 1.01; 1.02; 1.03.... 99.99, 100.00

Is it possible?

Any suggestion?

Sep 25 '07 #3
Vinnie,

My example should have incremented by 0.01, not 1.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"vinnie" <ce**********@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
When i try to populate a dropdownlist menu, using a for cicle works
perfect: i get a list of int from ie 1 to 10. How an populate my
ddlist if working on the code i wish to get not longer a series of
integers, but a series of decimals?

Like this:
old fashion: (for i=1; i<=100; i++) i get 100 integers;

New fashion) i want to populate the same list, but using the decimals:
1; 1.01; 1.02; 1.03.... 99.99, 100.00

Is it possible?

Any suggestion?

Sep 25 '07 #4
>
My example should have incremented by 0.01, not 1.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"vinnie" <centro.ga...@gmail.comwrote in message

news:11**********************@57g2000hsv.googlegro ups.com...

Hi Nicholais, it did, thanks a lot! :)

Sep 25 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mensan | last post by:
I am trying to compute the differnece between two dwords in visual basic and keep getting the wrong value being computed. I have the following structure defind: Public Type HighLowQuote...
5
by: Piotr B. | last post by:
Hello, I use MingGW g++ 3.2.3 on Windows 2000/AMD Athlon XP. I tried to output a "long double" variable using stdio printf(). I've tried various %formats (%llf, %Lf etc.), but none of them...
22
by: bq | last post by:
Hello, Two questions related to floating point support: What C compilers for the wintel (MS Windows + x86) platform are C99 compliant as far as <math.h> and <tgmath.h> are concerned? What...
4
by: michi | last post by:
Hello How can I convert a string to double with a decimal point as seperator? ***CODE**** strNumber ="12.00" dblDouble = Cdbl(strNumber) ****
12
by: Zero | last post by:
Hi everybody, i want to write a small program, which shows me the biggest and smallest number in dependance of the data type. For int the command could be: ...
2
by: anon.asdf | last post by:
Hi! Q. 1) How does one write: sizeof(array of 5 "pointers to double") ??? I know that sizeof(pointer to an array of 5 doubles) can be written as: sizeof(double (*));
19
by: glchin | last post by:
Does a compiler guarantee that the variable w below is placed on an eight-byte aligned address? void myFunction( long iFreq ) { const double w = two_pi * iFreq; ... ... }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.