|
See here.[^]
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Good find! I'll just save that one in my Favorites.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Enjoy, I've been using it on and off for a year or so.
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
but can u tell me then is there somthing right and why it does not end with 20
<code>#include <stdio.h>
int main()
{
int a ,i[20];
a=20;
for (i=0; i<a; i=+2)
{
printf("%i");
}
return 0;
}
</code>
|
|
|
|
|
There are really many things wrong.
#1: the for loop should be either i=i+2 or i+=2
#2: you're not assigning values to the array i
#3: you're using i (which is an array) as the variable in the for loop.
|
|
|
|
|
You forgot one - it's C code, in a C# forum.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Hi! Welcome to code project. Since this was your first post, let me remind you of something that you may have glossed over when setting up your account and making your first post.
Firstly, we don't do work for you. Well, unless you're going to pay us. CP is a community of people who help each other through issues, and learn from each other's mistakes/trials/succeesses.
Is this homework? Seems like it, especially with a problem that simple.
Are you looking for the specific object to use to hold that collection of numbers, or why one collection might be better than another?
Are you looking for advice on the methods to generate that sequence, whether to use a foreach statement, for loop, while loop, or do while loop? We'll probably be able to give you advice on your case as well.
What have you tried so far? Tell us what hasn't worked, and we'll give you advice on how to make it work, or other things to try that might work better.
|
|
|
|
|
i want do know why this program doesnt end can u give me advise `?
|
|
|
|
|
First, this is the C# forum, not the C or C++. There are seperate forums for them.
Next, it doesn't end because of your for statement. THere is something very wrong with the end of that line. What's wrong with the bolded part and what is that clause, as you've written it, actually doing?
for (i-0; i<a; i=+2)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I think you wanted +=, not =+.
As someone said, you need to post in the right forum, this is C#.
Also, your first port of call should be to set a break point in your program, then you can step through and see why it's behaving as it is. F9 sets a breakpoint, F5 starts debugging.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: I think you wanted +=, not =+.
Damn it man, don't give him the answer! It was so simple to fix, I left it as an excersize for him. I just pointed him at where the problem was...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
*grin* sorry, I missed that one. I replied mostly to point out the debugger option.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
thank u all , it works now
|
|
|
|
|
aavak! This is ur Professor Ulhas, from university.
when I gived out the ass ignments for homeworks and maths i tell you never to post it on the CPians internet pages. but here i find you posting it. u make me love hating you for your cheatings!!!!
when you get back to class tomorrow I will have to give you blackened grade and corporal punishment with many dire consexuences. i must also summon the winter solstice gods on your eternally damned soul for ur cheatings. even teh baby jesus hates u.
Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas
|
|
|
|
|
I take it you don't teach English grammer
He's a very naughty boy
Blog Have I http:\\www.frankkerrigan.com
|
|
|
|
|
mr kerrigan
you inslut the good and freindly professor ulhas? do you want, are you asking, for summoning of cursings of shiva on you?! i hope not so. maybe you bring the cheatingers on cpian internetp ages with u consexquences.
Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas
|
|
|
|
|
hi,
I have a datagridview on windows app(.net 2.0). I wanted to provide user with flexibility of changing any cell values within datagridView. In doing so, i wanted to check if datatype of the cell gets validated. When user updates the value within the datagridView, I want to check the OLD DATATYPE and NEW DATATYPE of the data. Meaning, I want to know beforehand what datatype the column allows and what datatype is the text user typing in.
I tried this:
object gridCellValue;
void repriceQuedataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
gridCellValue = repriceQuedataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
}
void repriceQuedataGridView1_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
{
Type sourceType = e.ColumnIndex.GetType();
Type changedDataType = e.Value.GetType();
Console.WriteLine(sender.GetType().ToString());
if (!sourceType.Equals(changedDataType))
{
MessageBox.Show("Please try again. Expected type is: " + e.ColumnIndex.GetType().ToString());
e.Value = gridCellValue;
e.ParsingApplied = true;
}
}
However,
Type changedDataType = e.Value.GetType(); line always gets datatype string because e.value is string. I want to check if lets say the original column allows int then the new value that user enters is of type int.
I want to write these events in such a way that it is GENERIC FOR ANY DATATYPE.
Please shed some light.
Thanks
Needy
|
|
|
|
|
Here is one approach:
void repriceQuedataGridView1_CellParsing(object sender,
DataGridViewCellParsingEventArgs e)
{
try
{
object convertedValue = Convert.ChangeType(e.Value, e.DesiredType);
}
catch
{
MessageBox.Show("Please try again. Expected type is " +
e.DesiredType.ToString());
DataGridView gridView = (DataGridView)sender;
if (Convert.IsDBNull(gridView.CurrentCell.Value))
{
gridView.CurrentCell.Value = string.Empty;
}
e.Value = gridView.CurrentCell.Value;
e.ParsingApplied = true;
}
}
Hope this helps.
|
|
|
|
|
Thank you Lisa. I will post if any problem occurs.
I appreciate your help.
Thanks
Needy
|
|
|
|
|
I have a Form from which a button click will open another form. Is there a way I can control the exact location of the second form on the screen (where the window will be displayed).
|
|
|
|
|
Yes. Pass the coordinates in the form's custom constructor and set the form's Location property in its Loaded event.
/ravi
|
|
|
|
|
Set the initial location property so that it's not predetermined, then set the values before calling the ShowDialog method.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Guys..
I want to try make GIS project for seraching shortest path. I want to try C#. Anybody can help from where should i start?
Thanks.
|
|
|
|
|
Shortest path? That's what the van Dijkstra and A* algorithms are for.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|