|
Convert the number to a string, then loop through the characters in that string.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
int.MaxValue is 2147483647. (Which is 10 digits).
Without using a 'bigger' space to store an integer (Int64) this will only 'fire' once if at all.
If this is true and you are using an int then if (myInt > 999999999)... will be sufficient.
If the integer is in string form then myStr.Length / 10 will give you the number of 'ten digits' there are in the string.
Matthew Butler
|
|
|
|
|
MasterSharp,
I think you've misunderstood the foreach slightly.
Foreach (int currentInt in myInt)
currentInt is the current int the foreach is at in the iteration.
myInt is the collection you want to iterate through.
So, if you wanted to fire an event every 10 digits, you could do:
int myInt = 100;<br />
int tenDigit = 0;<br />
foreach (int currentInt in myInt)<br />
{<br />
if (tenDigit == 10)<br />
{<br />
tenDigit = 0;<br />
<br />
If (Event != null)<br />
Event(this, new EventArgs());<br />
}<br />
<br />
tenDigit++;<br />
}
Hope this helps.
Regards,
Gareth.
|
|
|
|
|
Yes, thank you all.
- I love D-flat!
|
|
|
|
|
gareth111 wrote: int myInt = 100;
int tenDigit = 0;
foreach (int currentInt in myInt)
myInt is an integer. Foreach requires a collection, or some object that has an enumerator defined.
Small angry dogs
My 1000th post!!
|
|
|
|
|
Malcolm Smart,
Ye. My mistake, was thinking of just a normal for();
Regards,
Gareth.
|
|
|
|
|
In regards to Gareth's post, you can't use foreach on non-array objects.
|
|
|
|
|
Jordanwb,
See above.
Regards,
Gareth.
|
|
|
|
|
|
Hey all,
I would like, if possible, you could tell me some ideas for projects.
I have a friend who needs my help doing his final project but i run out of ideas. I think helping him will help me keep the C# programming skills i got from you guys.
Thanks so much, any help is greatly appreciate it!!
Best regards
Luis E Tineo S
|
|
|
|
|
kingletas,
Final project?, as in University?
Regards,
Gareth.
|
|
|
|
|
kingletas wrote: I have a friend who needs my help doing his final project
Your friend is best asking his instructor for guidance. That is what they are supposed to be there for.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote:
Your friend is best asking his instructor for guidance. That is what they are supposed to be there for.
I agree on that. I asked my friend to find out what kind of project or field his professor wanted but all my friend got from him was a "Think what you would like to do and we talk on Tuesday."
This is very important because this is like one big step to graduate from University.
Another thing is that my friend doesn't really know a thing about programming or hardware, so basically i will be tutoring/helping him build the project from the beginning to the end. I know there are a lot of "ethic/moral" principles involve and it might be wrong to do it. But as long as i don't cross the line between helping him to do it and do it myself i think it will be ok.
I thought of a: "Vehicle with a camera and fingerprint reader to ID the driver and the passengers" good for companies with no passengers policies. This is project is more suited for my country Dominican Republic where people tends to give a ride to anyone.
Also i thought of Mobile/smartphone application that constantly send a message where the owner is located, but the fact of violating the principle of privacy makes me uncomfortable; so i am about to discard that idea.
I have this tools, maybe it will help to know i have them:
* Microsoft Visual Studio 2005
* Microsoft Sql Server 2005
* Microsoft Finger Print Reader & the GrFinger SDK
* An extra low resolution small camera
* If it is needed i can get a GPS receiver.
* 2 PDA with WM 5
* Belkin Bluetooth adapter
* a few Atmega 8 with the "programmer"
Again Thanks for the help,
Best regards.
Luis E Tineo S
|
|
|
|
|
kingletas,
If your friend is not a programmer, do you think he will be able to do your idea of a camera and finger print reader?, with that idea, you will be writing it your self. I think you should go for something FAR simpler: a CRM app (SalesForce.com) or a content management website like Blackboard.com.
Think SIMPLE.
Regards,
Gareth.
|
|
|
|
|
kingletas wrote: my friend doesn't really know a thing about programming or hardware
What is he majoring in?
kingletas wrote: "Vehicle with a camera and fingerprint reader to ID the driver and the passengers"
For someone who really isn't a programmer, this would be very bad. Try something simple.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
hi guys, i am writing a application, i have 3 textboxes which are called "items", "Cost", and "Date". i write text into them click an "add" button then i want this data to go in to the datagrid which as columns named items, cost and date. could someone please tell what code to put in the add_click event? thanks
|
|
|
|
|
There should be an Add method for adding new rows to the datagrid.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
//Create a new instance of DataSet
DataSet objDataSet = new DataSet("TableName");
//Create a new DataRow in the DataSet
DataRow objDataRow = objDataSet.Tables["TableName"].NewRow();
//Assigning text values to their respective data columns
objDataRow["items"] = txtItems.Text;
objDataRow["cost"] = txtCost.Text;
objDataRow["date"] = txtDate.Text;
//Adding the row in the DataSet
objDataSet.Tables["TableName"].Rows.Add(objDataRow);
|
|
|
|
|
Good job doing his work for him. You didn't add any real learning value for him by doing it for him.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
this builds fine but there is null exception coming up when i try to input data on the line where the new row is created, am i right in thinking this needs a value? if so what value can i give it?
|
|
|
|
|
I am developing an application that combines images. I have one form that communicates with a webcam and another that communicates with a signature pad and the main form. My problem is that I want to display the image that my webcamm takes in a picturebox on the main form. Any ideas?
a novice
|
|
|
|
|
Ofori Boadu wrote: Any ideas?
Maybe google...
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Hi,
I am trying to select from two tables and concat two values. Thus, i should get a result of "324324234, gareth111".
SQL is below as well as the error.
SELECT UNet_Engineer.EngineerId + ', ' + UNet_Login.Username FROM UNet_Engineer, UNet_Login WHERE UNet_Engineer.EngineerId=UNet_Login.EngineerId;
DbConnection.ExecuteSelect; Exception: System.Data.OleDb.OleDbException: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.<br />
Data type mismatch in criteria expression.<br />
at System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr)<br />
at System.Data.OleDb.OleDbDataReader.GetRowDataFromHandle()<br />
at System.Data.OleDb.OleDbDataReader.GetValueBinding(MetaData info)<br />
at System.Data.OleDb.OleDbDataReader.GetValues(Object[] values)<br />
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)<br />
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()<br />
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)<br />
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)<br />
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)<br />
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)<br />
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)<br />
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)<br />
at UNet.Manager.Database.DbConnection.ExecuteSelect(String sql) in D:\UNet.Manager\Database\DbConnection.cs:line 90
Any ideas?
Regards,
Gareth.
|
|
|
|
|
What data type is UNet_Engineer.EngineerId ? If it is numeric, you need to cast it to a string data type before attempting the concatenation. CAST(UNet_Engineer.EngineerId AS VARCHAR) should do it.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I changed the SQL as you said, but it produced a new error.
SELECT CAST(UNet_Engineer.EngineerId AS VARCHAR) + ', ' + UNet_Login.Username FROM UNet_Engineer, UNet_Login WHERE UNet_Engineer.EngineerId=UNet_Login.EngineerId;<br />
<br />
DbConnection.ExecuteSelect; Exception: System.Data.OleDb.OleDbException: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)<br />
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)<br />
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)<br />
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)<br />
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)<br />
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)<br />
at UNet.Manager.Database.DbConnection.ExecuteSelect(String sql) in D:\UNet.Manager\Database\DbConnection.cs:line 90
Regards,
Gareth
|
|
|
|
|