|
You can look at Int32.TryParse . To convert to int. The difference between .TryParse() and Convert is that Convert will throw you an exception if it cannot convert. Forgot witch one it is. TryParse will return false if faild. My preferences is Convert method
|
|
|
|
|
mjawadkhatri wrote: textbox should autogenerate a number everytime when user insert new record
Insert a record where? Because if the answer is a database then the database should be generating the number - not your application.
|
|
|
|
|
How to make setup of window application in .net of 10 days block. Means software will work for 10 days only.
|
|
|
|
|
There are many ways of doing this. The easiest (though least secure) way of doing this is to store the date it was installed into a text file and then check that file each time the application loads. If 10 days have elapsed, then exit.
|
|
|
|
|
But if user has changed the system date then it will not work
|
|
|
|
|
people can delete the txt file also right? Then the application can continue work?
|
|
|
|
|
Hi. We're having a little problem in allowing the user click/press any button from a group of buttons inside a panel. What we want is after clicking/pressing one button that is not one of the group of buttons, the user will be allowed to click/press any of the buttons in the panel. All the buttons inside the panel represent the alphabet that's why we want to do that. The button that will be clicked before doing that is a start button. So can anyone help us?
|
|
|
|
|
So you start off with the buttons enabled property as False then when the start button is clicked you go through each control in Panel.Controls and if it is a button and not the start button set the enabled property to True.
You may want to put the alphabet buttons in a groupbox to further segregate them from any other controls, in this case you go through the GroupBox.Controls collection instead.
|
|
|
|
|
I am counting words in string, that i get from text file. Using this code i get always 1 more word in counting. What could be wrong?
int stevec = 0;
string s="avc sde s a s"
string[] words = Regex.Split(s, @"[\S]+");
foreach (string word in words)
{
stevec++;
}
After deb stevec has value 6. But there are only 5 words.
|
|
|
|
|
I tested your regex.. Making the S lowercase did the trick.
Regex.Split(s, @"[\s]+"); Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
gee. Did you consider looking what is inside the words array? to fix a faulty program, you need to open your eyes and look around. Nobody is going to do that for you.
If you get all the facts, and still can't figure it out, then post a real question, clear and well documented.
|
|
|
|
|
Sorry.. while i was debuggin i couldn't see words with breakpoints, even in console they weren't visible. And with greater S using only Regex.Match the counting was correct, thats why i asked here. Anyway, thanks for help.
|
|
|
|
|
there are many debugging tools, the simplest one is Console.WriteLine; it works always, never had a problem with it.
|
|
|
|
|
@"[\S]+" should be replaced by @"[\s]+".
"s" should be the lowercase.
April
Comm100 - Leading Live Chat Software Provider
|
|
|
|
|
Does the .NET framework have built-in support for creating, manipulating, and extracting files from Windows Zip files?
If not the .NET framework, does the Win32 API have functions for that?
Thanks.
|
|
|
|
|
The .NET framework doesn't have any built-in "ready-to-use" methods for working with ZIP-files.
You may wanna have a look at SharpZipLib[^] which is a .NET zip library written in C#. Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
Thanks for that, I've downloaded it.
But how does the Windows Shell handle Zip files? Doesn't it have its own API for that?
|
|
|
|
|
It uses the shell extension zipfldr.dll
(but it sucks, and why wouldn't you use SharpZipLib?)
|
|
|
|
|
I will.
|
|
|
|
|
Yeah, it does. But do you really want to rewrite all the C-based function headers and structure garbage in C#, or do just want to use a good library that already exposes all this stuff for you nicely?
In other words, do you want to manipulate .ZIP files in another week, or get it done today?
|
|
|
|
|
You're right, I didn't realize all that was involved the other way.
|
|
|
|
|
|
I was just asking for info's sake. I think I will use the library you suggested.
|
|
|
|
|
An alternative to the previously mentioned SharpZipLib is DotNetZip[^]. I worked with it on a recent project and found the API a little bit easier to understand and use.
|
|
|
|
|
SharpZipLib and DotNetZip as suggested before are probably your easiest bets, but since you asked, yes the .Net framework does have built-in classes for handling zip files. However, they are J# classes and use java.util.zip. Here's an article on using the J# classes in a C# application: http://msdn.microsoft.com/en-us/magazine/cc164129.aspx[^]. Don't blame me. I voted for Chuck Norris.
|
|
|
|