Inserting flags based on user-input
I have a small software inside which there is a facility to select which country, Now i have a database of around 150 flags uploaded to My.Resources.
I first started using this code.
Code:
Select Case TextBoxCountry.Text
Case is = "England"
PictureBox.image = My.Resources.England
Case is = "USA"
PictureBox.image = My.Resources.USA
Case is = "Austraila"
PictureBox.image = My.Resources.Australia
and soo on,
But do i have to do this to all the 150 flags?? isn there a simple way??
I have named all the resource images to the names of their country exactly. Eg: India.jpg, Australia.jpg etc
Cant i use this somehow??
And is there a way that i can make it case-insensitive so that if the user enters it in improper case also it will recognise it??
Thank You.
Re: Inserting flags based on user-input
I have a class in my signature where I handle just that. It's titled "Country Flags", take a look at that and see if that helps you out.
Re: Inserting flags based on user-input
Good work dday, but my initial though would be to load the data into a database.
Re: Inserting flags based on user-input
Thank you :]
Quote:
my initial though would be to load the data into a database.
See that's what I thought I should've done, but I figured the dictionary was universal enough to apply to everyone. I thought, what if one was using MySQL, Oracle, or Access, I couldn't just use SQLCompaq(which is what I've started using).
Re: Inserting flags based on user-input
no need for an extensive select case block or utilizing a database. 1 line:
Code:
PictureBox1.Image = DirectCast(My.Resources.ResourceManager.GetObject(StrConv(TextBoxCountry.Text, VbStrConv.ProperCase)), Bitmap)
Re: Inserting flags based on user-input
Quote:
Originally Posted by
.paul.
no need for an extensive select case block or utilizing a database. 1 line:
Code:
PictureBox1.Image = DirectCast(My.Resources.ResourceManager.GetObject(StrConv(TextBoxCountry.Text, VbStrConv.ProperCase)), Bitmap)
Thank You very much :) It worked.
I have one more doubt.
Now to enter the name of the country i have given the user an InputBox, But what i want is a Something like a suggestion box that suggests the name of the country as the start typing the first few letters, so that they will be able to select a country rather than type in a name for which they might not kno the correct spelling.
Im a 3 month old new bee in this field, Please help me out if you can :)
Re: Inserting flags based on user-input
Have a look at this thread on VBForums, particularly Post #4 which also gives a link to MSDN documentation.
If you want to use a TextBox, the MSDN documentation should be especially useful.
Re: Inserting flags based on user-input
I think that you have to implement it for all 150 flags, there is no other option for you.