|
I tried that originally but it would either a. work or b. work but bring a random number that didn't make sense or c. didn't work at all. The size of int x as you put it...is completely random it could be 50 one time and 234503 the next. So it isn't a static variable. Here is the piece of Code I'm working on.
<br />
private void ButtonTotal_Click(object sender, System.EventArgs e)<br />
{<br />
int intPrimary;<br />
int intBuild;<br />
int intFuel;<br />
int intTotal;<br />
int intCP;<br />
int intSP;<br />
int intGP;<br />
int intPP;<br />
<br />
intPrimary = (Int32.Parse( PrimaryCost.Text) * Int32.Parse( PrimaryQuan.Text ));<br />
intBuild = (Int32.Parse( CompCost1.Text ) * Int32.Parse( CompQuan1.Text )) + <br />
(Int32.Parse( CompCost2.Text ) * Int32.Parse( CompQuan2.Text )) +<br />
(Int32.Parse( CompCost3.Text ) * Int32.Parse( CompQuan3.Text )) +<br />
(Int32.Parse( CompCost4.Text ) * Int32.Parse( CompQuan4.Text ));<br />
intFuel = (Int32.Parse( FuelCost.Text ) * Int32.Parse( FuelQuan.Text ));<br />
intTotal = ( intPrimary + intBuild + intFuel )* Int32.Parse( Times.Text );<br />
<br />
intCP = intTotal % 40;<br />
intSP = intTotal % 40;<br />
intGP = intTotal % 40;<br />
intPP = intTotal % 40;<br />
<br />
TotalCP.Text = Convert.ToString( intCP );<br />
TotalSP.Text = Convert.ToString( intSP );<br />
TotalGP.Text = Convert.ToString( intGP );<br />
TotalPP.Text = Convert.ToString( intPP );<br />
}<br />
|
|
|
|
|
I would probably use string parsing.
str = intTotoal.ToString("#");
lbl1.Text = str.SubString(str.Length - 2,2);
lbl2.Text = str.SubString(str.Length - 4,2);
lbl3.Text = str.SubString(str.Length - 6,2);
lbl4.Text = str.SubString(0,str.Length - 6);
Remember to put an 'if' test before each statement to check if the string is long enough to do the SubString requested.
|
|
|
|
|
it says i need a definition for SubString and Length.
|
|
|
|
|
Sorry,
It's Substring not SubString. Thats what I get for relying on intellisense too much. Here is working code copied from the vs editor:
int i;
string str;
i = 1234567890;
str = i.ToString();
lbl1.Text = str.Substring(str.Length - 2,2);
lbl2.Text = str.Substring(str.Length - 4,2);
lbl3.Text = str.Substring(str.Length - 6,2);
lbl4.Text = str.Substring(0,str.Length - 6);
Substring and Length are members of System.String
As long as you have "using System;" at the top of your *.cs file, you should be able to use code like this.
|
|
|
|
|
it worked thanks...sorry if I had sounded stupid I've only been programming for about 3 weeks.
|
|
|
|
|
Actually It works the first time I run it...then after that it comes up with this error.
[code]An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: StartIndex cannot be less than zero.[/code]
Any ideas?
|
|
|
|
|
Obviously your string is to short, so that the expression str.Length - 2 and/or str.Length - 4 and/or str.Length - 6 is/are less than zero and the String.Substring method fails (remember the random length of your number).
So you should check the length of the string before you retrieve the substrings.
P.S: If you reply to your own posting, you're the only one that gets notified and as this thread is pretty old, most likely nobody will ever see your new posting.
www.troschuetz.de
|
|
|
|
|
hello
i am developing a term project of sending sms in pakistan and aslo world wide i have searched so many webservices.one is tiscali webservices. actually when i send message the notification message appear that message has been sent but i did not receive message please help me give me early reply and please send me links of webservices. thanks. ok bye
|
|
|
|
|
Hello dear all
now i am working C# technology and i am developing a application software. i am using a tree view control and having one problem in tree viwe control when i have expand all the node and if tree is refersh then all expained node colleps
Please help how we can expand again all node after referesh the tree view control by programming.
|
|
|
|
|
I have a big problem :
I'm also trying to control the port[open port , close port ,...] and i write the following code in C#:
Socket serialPort1 = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
System.Net.IPAddress LocalIPAddress = System.Net.IPAddress.Parse("127.0.0.1");
System.Net.IPEndPoint LocalEndPoint = new System.Net.IPEndPoint( LocalIPAddress,80 );
serialPort1.Connect(LocalEndPoint);
serialPort1.Blocking = false;
serialPort1.Shutdown(SocketShutdown.Both);
serialPort1.Close();
I think after the program execute i cann't open any web page because the port (80) as the http and when i closed it i cann't open any web page .
but in fact after the program execute not happened any thing i can also open any web page ????!!!!!
what is the wrong in last code ????!!!
Please some one help me
thanks.
|
|
|
|
|
You can't shutdown a remote socket by closing your end. Once a connection gets established with the server, the server communicates to the client using a different port. When you shutdown the connection, it is that port that closes down.
In your case, the webserver will keep running. Just think of it, if a webserver shuts down simply because a client closed a connection, it would be unusable..
Regards
Senthil
|
|
|
|
|
Hello,
I need to be able to find the first row where the first eight columns are empty. Right now I just get a cell range, loop through the first eight values, and if I didn't find anyhting, then the row is empty (at least the first eight cols are empty) and I continue to the next row.
Is there a method that already exists that I can use to achieve the same results? It seems inefficient to have to read the first eight values of every row until you find an empty one. If I hae many rows, and the next to last one is empty, it would take a while to find that out.
It would also be ok if I could fid the first totally empty row.
I looked at the UsedRange of the sheet but it includes empty lines in its range.
Thanks for the help,
-Flack
|
|
|
|
|
I know what you mean, I think the UsedRange includes any cell that has formatting, which can be quite annoying.
Try this
Range rng = Sheet1.UsedRange;<br />
object[,] data = null;<br />
data = (object[,])rng.Value;<br />
Marshal.ReleaseComObject(rng);
Looping through the array is much faster then looping through cells.
|
|
|
|
|
Don't know if this will help you, but I'll give it a try. In my VBA makros I use the following code and it works great.
ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
/* Edit
The above code returns the last non-empty row, so you'll have to increase the result by one
*/
www.troschuetz.de
|
|
|
|
|
I have read enough about Alternate Data Streams (ADS) to know that copying files from an NTFS file system to (say) FAT32 will lose them; and I think it may be possible to use one CD-R format (?UDF) and retain them.
Also, I have corresponded with the WinZIP folks and they say that they have occasionally had requests for the ADS to be archivable in their ZIP package, but it's not a large enough number of requests for them to include it as a feature.
I am designing an application that uses ADS to keep extensive metadata (well beyond Custom properties, and moderately large amounts of text and XML) that describe GIS files, and would like to be able to retain the streams on a medium such as CD-R or DVD.
What alternatives do I have to do that?
I would prefer to write something myself using C# or VB.NET - so the useful APIs would be a first step.
Perhaps someone with some experience in programming against the NTFS system and its data streams could give me a few pointers?
Ian Thomas
|
|
|
|
|
First of all, I'm fairly new at programming in C#, so if my question seems rediculously simple, I apologize.
I'm trying to build an application that uses the OldDbConnection (Jet 4.0) to access a Microsoft Access .mdb file. So far, the only way I've found to get it to link up properly is to give it the full path of the database file. This is fine for my system, but I want to be able to package it up and share it. Is there a shorthand path I can give it to indicate that the database file is in the same directory as the executable, or will I need to set up some variable?
If I'm going to have to store the path somewhere, what is the preferred way to do that in .NET?
Again, I realize that some of the questions deal with basics, but I've gotta start somewhere. Any help would be greatly appreciated.
--In a world without fences, who needs Gates?
|
|
|
|
|
Application.StartupPath should give you the executable's path. Check here[^].
Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
hello can some one plase help me construct a list in c# that will do this
example on a list
name = new list();
name.myname = "michael hansen";
subname = new list();
subname.myname = "michael son martin";
subname = new list();
subname.myname = "michael sister jane";
just a little example what the list will look like
michael hansen root
---------son martin child
---------sister jane child
claus hansen new root
---------son martin child
---------sister jane child
and so on
i must be in Inode or list or item function in c# it has to be fast
no use of treeview or xml or any part of controls
just plain linked list wiith a like parant and child
plase mail at michaelhansen555@msn.com
if some one have a source code for that kind of list
tanks
best regards
michael hansen
|
|
|
|
|
Use Beta 2.0 System.Collection.Generic
LinkedList<>
Or try To use ArrayList
Dynamic Array.
|
|
|
|
|
|
Hi Everyone,
I have a question, and I really don't know how to make it works. The questio
ns is that I have a LinkButton Column on a DataGrid table.
:
protected System.Web.UI.WebControls.DataGrid dgInfo;
:
dgInfo.Items[j].Cells[1].Text = "MyData";
:
:
After I change the cell text to "MyData", the cell losts the link. Does ther
e have any way to change the LinkButton text to two different texts and keep
the link button attribute?
Thanks a lot ....
|
|
|
|
|
I would like to change the color of the FixedSingle BorderStyle in the PictureBox from Black to Red
How Can i Do it??
C# Winforms
|
|
|
|
|
Why can't the as operator perform user-defined conversions?
Is it a C# problem or with MSIL? I can't see any reasons why the compiler should'nt be able to use a user-defined conversion operator. Anyone knows the answer?
MSDN
my c# blog: C# Coach
|
|
|
|
|
I am confused... you never need to do that. Perhaps you are looking for explicit casting, but that will only work as reference type. Btw, have u looked at the output of an as expression in MSIL? That will show you the what actually happens when it is used.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Hi Everyone,
I have a question, and I really don't know how to make it works. The questions is that I have a LinkButton Column on a DataGrid table.
:
protected System.Web.UI.WebControls.DataGrid dgInfo;
:
dgInfo.Items[j].Cells[1].Text = "MyData";
:
:
After I change the cell text to "MyData", the cell losts the link. Does there have any way to change the LinkButton text to two different texts and keep the link button attribute?
Thanks a lot ....
|
|
|
|