473,785 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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 1506
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.co m

"vinnie" <ce**********@g mail.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.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.co m

"vinnie" <ce**********@g mail.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.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.c om

"vinnie" <centro.ga...@g mail.comwrote in message

news:11******** **************@ 57g2000hsv.goog legroups.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
3250
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 TradeDate As String OpenPrice As Double HighPrice As Double LowPrice As Double ClosePrice As Double
5
23102
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 worked... The same source compiled with Borland C++Builder 5.0 works for %Lf format. How to get the same results with MinGW g++ ?
22
3725
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 wintel compilers support a 16-byte "long double" (with 33 decimal digits of accuracy) including proper printf() support. I found some compilers that did support "long double", but theirs was an 8-byte or 10-byte or 12-byte type with accuracy the...
4
8004
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
43468
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: printf("\n%20s\t%7u\t%13i\t%13i","signed int",sizeof(signed int),INT_MIN,INT_MAX);
2
2181
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
4144
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
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6742
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4055
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 we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.