|
-
May 7th, 2013, 10:48 AM
#1
Thread Starter
Member
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.
-
May 7th, 2013, 10:52 AM
#2
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.
-
May 7th, 2013, 01:20 PM
#3
Re: Inserting flags based on user-input
Good work dday, but my initial though would be to load the data into a database.
That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma
Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney
-
May 7th, 2013, 01:32 PM
#4
Re: Inserting flags based on user-input
Thank you :]
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).
-
May 7th, 2013, 01:37 PM
#5
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)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 9th, 2013, 01:43 AM
#6
Thread Starter
Member
Re: Inserting flags based on user-input
 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
-
May 9th, 2013, 03:48 AM
#7
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.
-
May 9th, 2013, 07:54 AM
#8
Junior Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|