|
Hi,
(I'm a C# guy, so when I say null you read Nothing)
A combobox holds a collection of items; their type can be anything (they are
Objects); often they are strings.
For selection you have properties:
SelectedItem: is an object, should be in the collection, or null
SelectedIndex: is an int, the index in the collection (zero based), or -1 for none
SelectedText: the result of SelectedItem.ToString(), or null/"" (not sure)
Test:
bool somethingGotSelected=cb.SelectedItem!=null;
Clear:
cb.SelectedItem=null;
Check the documentation, read about combobox, use MSDN;
and try to understand what you are doing !
you cant do cb.SelectedItem.ToString since SelectedItem could be null.
you cant do cb.SelectedItem="" unless "" is in the list
good luck.
|
|
|
|
|
i think with .net indexing, when no object is selected the selected index is set to -1. With a listbox you go:
if me.listbox1.selectedindex = -1 then<br />
' you know nothing is selected<br />
end if
It should be the same for the combobox. Same with the ressetting, probably set the selected index to -1.
|
|
|
|
|
Could anyone tell me what code I shall use to validate input string in all char and numeric, like using ASCII, please? Providing code examples is very appreciated.
Thank You Very Much. Ryan
|
|
|
|
|
You could validate through regular expressions...
alurora wrote: Providing code examples is very appreciated.
Google around, there are plenty of examples. Search on this site for Expresso, which is regular expression tool that is incredibly handy to have around
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I will not give examples, there is lots of documentation (MSDN(, and articles
everywhere (including CodeProject).
The keywords you could look for are:
MaskedTextBox
int.TryParse
double.TryParse
and for the most challenging validations: Regex class (which is difficult !)
|
|
|
|
|
Luc Pattyn wrote: which is difficult !
Yes, but powerful if I may add
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Sure, there would be little value in "difficult but not powerful".
Didnt seem to me like a good idea to stear the OP in that direction tho.
If unfamiliar with TryParse, what a question avalanche should we expect
from Regex attempts ?
|
|
|
|
|
Luc Pattyn wrote: Didnt seem to me like a good idea to stear the OP in that direction tho.
Yeah, maybe I did a little overkill on the question :->
Luc Pattyn wrote: If unfamiliar with TryParse, what a question avalanche should we expect
from Regex attempts ?
I'll try to take care of any snowballing that comes from regex questions
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: I'll try to take care of any snowballing that comes from regex questions
Too much spare time ? Or attracted by fixture status ?
|
|
|
|
|
Luc Pattyn wrote: Too much spare time ?
Yes, I have some time right now. Not sure what my time will look like when I start my new job in two weeks
Luc Pattyn wrote: attracted by fixture status ?
I'm almost there :->
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Check out my articles from the link in my signature. Both are on Validation.
|
|
|
|
|
alurora wrote: could anyone help me not to have the form minimise when the error messagebox popup, please?
I'm wondering what you did to make it do that?? I can't duplicate the problem with the code you've posted.
|
|
|
|
|
What??? I was looking through the Validation thread and ran across this orphan. What was the OP talking about as far as minimizing an error messagebox popup? Only thing I could think of is that he didn't mean MessageBox but some custom form that acted as a error messagebox...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
He was saying that his main form would minimize when he put up a MessageBox. I was wondering what he did to accomplish this feat.
|
|
|
|
|
Dave Kreskowiak wrote: I was wondering what he did to accomplish this feat.
That is odd. One way I think he could have done it was by having the code invoke a minimize window message before going to the MessageBox.
"But your mind is too small and simple to understand anything other than fart jokes." - leckey advising a certain troll
|
|
|
|
|
I'm using VB.NET2005. Could anyone here tell me how do I change a date format to simple one, just:ddmmyyyy, and WITHOUT time display, please?
Thank You Very Much. Ryan
|
|
|
|
|
alurora wrote: Could anyone here tell me how do I change a date format to simple one, just:ddmmyyyy, and WITHOUT time display, please?
I presume you have a DateTime object of some sort. It has a ToString() method that takes a formatting string.
e.g. myDateTime.ToString("ddMMyyyy") will give you what you want.
Becareful of the capitalisation mm == minutes and MM == months.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
if it is a datetime object simply:
mystring = mydatetime.ToShortDateString
|
|
|
|
|
Apart from using " " as spacing syntax in vb.net, whether have any other command can represent it?
finalresult += (str_f_data(c)(1) + " " + str_f_data(c)(2) + " " + str_f_data(c)(3) + " " + str_f_data(c)(5))
Whether the space can be overwritten? The length for my array is different (in same column with different length). I want to make them located in same starting position after print out.
-- modified at 12:52 Saturday 28th July, 2007
|
|
|
|
|
You might want to look at the String.Format method.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
|
There are plenty of examples out there, including in the documentation for the .NET Framework. You might want to learn what String.Format() can do rather than copy and paste an example someone made for you. That way the next time you will be able to do it yourself.
Seriously, String.Format() is in just about every good beginners book to .NET or VB.NET
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Dim final_oWrite As System.IO.StreamWriter<br />
final_oWrite = System.IO.File.CreateText(File_result)<br />
<br />
If System.IO.File.Exists(header_File) = True Then<br />
System.IO.File.Copy(header_File, File_result)<br />
End If<br />
<br />
final_oWrite.Close()
I would like to create the text file (File_result) and copy the content from header_File to File_result. It shows the message that file have alreay exists. How to overwrite the existing file.
|
|
|
|
|
use this overload method: File.Copy (String, String, Boolean)
3rd argument is for overwrite.
--------------------------------
txtSignature
|
|
|
|
|
After i put in true inside the bracket and run the program, it show me the message "the process cannot access the file because it is being used by another process.
|
|
|
|