|
I don't know how many smack i got from Mr.Kreskowiak for this sort of spoon feeding which reflect in my answer submissions. .
Sreejith Nair
[ My Articles ]
|
|
|
|
|
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Here is the code I am using to get the total of the following textboxes
int OnHandVar1=Convert.ToInt32(OnHandRow1.Text);
int OnHandVar2=Convert.ToInt32(OnHandRow2.Text);
int OnHandVar3=Convert.ToInt32(OnHandRow3.Text);
int OnHandVar4=Convert.ToInt32(OnHandRow4.Text);
int OnHandVar5=Convert.ToInt32(OnHandRow5.Text);
int OnHandresult= OnHandVar1 + OnHandVar2 + OnHandVar3 + OnHandVar4 + OnHandVar5;
TxtOnHand.Text =Convert.ToString(OnHandresult);
actully for the other things the code is working just fine and also before it was working fine, now it is giving me an error saying that
"INPUT STRING WAS NOT IN A CORRECT FORMAT"
CAN SOMEONE PLEASE HELP ME OUT URGENT!!!!!!!!!!
Thanks,
I really appreciate your response.
Urgent
|
|
|
|
|
Zindagi11@rediffmail.com wrote:
"INPUT STRING WAS NOT IN A CORRECT FORMAT"
Gee. What do you think this might mean ? I'd guess that the input string was not in the correct format. I'd further guess that seeing as you're converting strings to numbers, that some of them were not valid numbers ( empty strings perhaps ? ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm not sure, but doesn't .NET create 0 for empty strings? Could be wrong though.
No hurries, no worries.
|
|
|
|
|
Like Christian said, the Text might be empty, or it's not a number.
<italic>Work hard, Work effectively.
|
|
|
|
|
To add on to Christian reply, your string might contain alphabets or non-digit characters. Perhaps you can run a Char.IsDigit(..) check on each characters in the string.
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
How do I handle empty strings in this particular code, I will really appreciate it.
Thanks,
ZIndagi
ZIndagi
|
|
|
|
|
This handles an empty value:
int OnHandVar1;<br />
if (OnHandRow1.Text.Length == 0) {<br />
OnHandVar1 = 0;<br />
} else {<br />
OnHandVar1 = int.Parse(OnHandRow1.Text);<br />
}
If the value is not empty and not numeric, it still gives an error, though.
---
b { font-weight: normal; }
|
|
|
|
|
is there a simple way to change background color of the row, based on its value...(based on cell value in same row)
|
|
|
|
|
"Simple" is a relative term, dependant on your definition and programming skill level, compared to someone else.
You might want to take a look at this[^] article by Piero.Viano.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi there friends,
I am working on a program that its language is not english(so mine!).
every time user wants to change the language he must press ALT+SHIFT
and this is annoying.How can I change language programatically?
Thank You!
|
|
|
|
|
i have a problem where, i need to display shared folders of a specified computer in a explorer. If i give a computer name, it should display the shared folders in a explorer. I could do that through wmi queries, but it is in not explorer view. The problem has to be solved in C#.
can anybody guide me?
Amar
|
|
|
|
|
I have binary files that have delimiters inserted to indicate document breaks. I need to break apart these files into these documents in C# and save each to a binary file. How would one go about this?
|
|
|
|
|
Leo,
To do this task, if your files are binary to begin with, you will need to use this code snippet to read the file :
System.IO.FileStream <name of="" variable=""> = new System.IO.FileStream("<name of="" file="">", FileMode.Open)
System.IO.BinaryReader <name of="" variable=""> = new System.IO.BinaryReader();
That will open the document for binary reading.
To read the document and convert it to a string for splitting, add this. (br will be used for the BinaryReader)
string <name of="" string=""> = "";
foreach(byte data in br.ReadBytes((int)fs.Length))
{
<name of="" string=""> = <name of="" string=""> + new String(data);
}
string[] <name of="" array=""> = <name of="" string="">.Split("<delimiter>".ToCharArray());
That seperates the string into an array so you can write the data with this:
This is setting up the writer from a Windows forms SaveFileDialog:
for(int i = 0; i <= this.saveFileDialog1.FileNames.Size; i++)
{
BinaryWriter[] bw = new BinaryWriter(new FileStream(this.saveFileDialog1.FileNames[i], FileMode.Create))[this.saveFileDialog1.FileNames.Size];
}
Now to write the individual data:
for(int i = 0; i <= this.saveFileDialog1.FileNames.Size; i++)
{
bw[i].Write(<name of="" array="">[i]);
bw[i].Close();
}
And that should do it.
Mike Stark
|
|
|
|
|
I want to know how to check the internet port status, becuse i want to create a TCP server application that can select the port dynamic, you know not static.
For example i want to check port 1313 from ip 127.0.0.1, i want to know status (is it opened or not), if opened i want to know who is open the port. Like port scanner you know, but this for socket application.
Thank's for your comments.
|
|
|
|
|
The only thing I can think of is that you try to programatically open ports in a while loop which has a try-catch inside to try to open the socket, and catch the exception and continue the loop...You can also figure out which specific exception will fire when the port is in use and only catch that one, but let other exceptions be thrown or just catch-all and assume that it's an already open-port.
|
|
|
|
|
|
I am working on a project and need the communities help. I have searched extensively, and cannot seem to find a solution to this problem.
I need to create a very simple properties grid. It should have no headers, and simply display 2 columns with name/value pairs listed one per row.
I have created this control by deriving a custom control from the DataGrid object, and it works well, except for one thing. The columns are not resizable without including a header column to the grid.
What I need to do is be able to resize the columns by clicking on the divider between the two cells on any row of the grid. This is the same behavior as what you see in the PropertiesGrid control.
Does anyone have any suggestions on how to implement this? It seems like this should not be hard to do, yet I have been unable to find any reference on where to even begin, much less an implemented solution to this problem.
Thanks in advance for everyones time.
Scot.
|
|
|
|
|
i have some piece of info which might get you further but it's for resizing columns according to the header text size.
piece of code is:
MethodInfo methodInfo = datagrid.GetType().GetMethod("ColAutoResize", BindingFlags.NonPublic | BindingFlags.Instance);
if (methodInfo == null)
return;
for(int i=0; i
|
|
|
|
|
Hi, I want to solve this problem, maybe yu can help me.
I have a lisview with filters, when perm any filter I clear an fill the listview with the filterde rows, the problem is when I have my lisview scrolled horizontally to the right and perform a filter, the listview scroll is moved to the left again to the star of the listview, I dont want this I wat the lisview mantain its scrolled position.
Thank you!!!!
Another question:
When I have both vertical and horizontal scrolls and clear the listview items, what happans with the horizontal scroll (vertical scroll desapear and listview resize (I think)). Resize? Move? and the lisview??
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Hi.
The only way I see without using unmanaged code is to not clear the listview but modify the ListViewItem s to reflect the new data.
When you remove a ListViewItem , the ListView has to check whether the remaining items can be displayed with or without scrollbars, so when you remove all items (clear the LV), then there will be no scrollbars at all, because 0 items will occupy no space.
Perhaps you could remember the scroll position and restore it afterwards, but that will include using P/invoke.
Regards,
mav
|
|
|
|
|
Hello all,
I've noticed an "interesting" behavior in winforms. If I have a custom control whose paint event is overridden to draw a gradient background. When the control is docked and I try to create a LinearGradientBrush by specifying colors and a rectangle, I get an Out of Memory exception. OutOfMemoryException is the most useless exception type, because it does not allow you to fix or even diagnose problems in your code. You are simply screwed as far as I can tell.
Does anybody have an idea why this happens when the control is docked, but does not occur at any other time (like when the control is anchored to achieve the same effect)?
Will
|
|
|
|
|
I guess you should verify the dimensions of your rectangle in either case...
Regards,
mav
|
|
|
|
|