Results 1 to 7 of 7

Thread: [RESOLVED] PROBLEM WITH COMBOBOX..important

  1. #1

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Resolved [RESOLVED] PROBLEM WITH COMBOBOX..important

    Hi everyone,

    I'm a newbee with vbnet ,I have a vb net 2005 and I write for pocketpc application ,
    I have 1 combobox and 5 values in it ,when I select 1 value from the cmbo it writes values in textboxes , what wrong with this code that it returns values only from case 1-4 ,and ignores the values of case 0?!

    please its very important..


    Code:
            If ComboBox1.SelectedItem() Then
                Dim ans As Double
                ans = ComboBox1.SelectedItem
                Select Case ans
                    Case -1
                        MessageBox.Show("יש לבחור את דרגת החספוס")
                    Case 0
                        TextBox3.Text = 0.153
                        TextBox4.Text = 0.003
                        TextBox5.Text = 1.0
                    Case 1
                        TextBox3.Text = 0.17
                        TextBox4.Text = 0.01
                        TextBox5.Text = 1.0
                    Case 2
                        TextBox3.Text = 0.19
                        TextBox4.Text = 0.05
                        TextBox5.Text = 2.0
                    Case 3
                        TextBox3.Text = 0.215
                        TextBox4.Text = 0.3
                        TextBox5.Text = 5.0
                    Case 4
                        TextBox3.Text = 0.234
                        TextBox4.Text = 1.0
                        TextBox5.Text = 10.0
    
                End Select
            End If

    Giving an exact answer
    Saves a lot of time!!!

  2. #2
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: PROBLEM WITH COMBOBOX..important

    Firstly and most importantly, yay for Tux :P

    Now to your question, the problem with your code was the way in which you checked to see if there was a selected item. When the SelectedItem was 0 the If statement was If 0 Then, and 0 is used to represent False in binary, which is why it wasn't working for 0.
    The following code would work;
    Code:
            If ComboBox1.SelectedItem IsNot Nothing Then
                Dim ans As Double
                ans = ComboBox1.SelectedItem
                Select Case ans
                    Case -1
                        MessageBox.Show("יש לבחור את דרגת החספוס")
                    Case 0
                        TextBox3.Text = 0.153
                        TextBox4.Text = 0.003
                        TextBox5.Text = 1.0
                    Case 1
                        TextBox3.Text = 0.17
                        TextBox4.Text = 0.01
                        TextBox5.Text = 1.0
                    Case 2
                        TextBox3.Text = 0.19
                        TextBox4.Text = 0.05
                        TextBox5.Text = 2.0
                    Case 3
                        TextBox3.Text = 0.215
                        TextBox4.Text = 0.3
                        TextBox5.Text = 5.0
                    Case 4
                        TextBox3.Text = 0.234
                        TextBox4.Text = 1.0
                        TextBox5.Text = 10.0
    
                End Select
            End If
    Anyway I hope this helps

    Satal

  3. #3

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Re: PROBLEM WITH COMBOBOX..important

    Hi Satar,

    Thank you very much for quick reply , it works but another thing , if I want to combine a condition -
    that if textbox1.text>200 then write message "it can't be design" how should I do it.

    Giving an exact answer
    Saves a lot of time!!!

  4. #4
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: PROBLEM WITH COMBOBOX..important

    Satar, that's a new one

    Code:
    If IsNumeric(TextBox1.Text) Then
        If TextBox1.Text > 200 Then
            MessageBox.Show("It can't be designed")
        End If
    End If
    Satal

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: PROBLEM WITH COMBOBOX..important

    Quote Originally Posted by noam309 View Post
    Hi Satar,

    Thank you very much for quick reply , it works but another thing , if I want to combine a condition -
    that if textbox1.text>200 then write message "it can't be design" how should I do it.
    These are very basic questions - I hope you are not going to post a new thread labelled URGENT or VERY IMPORTANT every time you have a question that you would know the answer to if you followed a simple VB.NET beginners tutorial...
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6

    Thread Starter
    Addicted Member noam309's Avatar
    Join Date
    Aug 2006
    Posts
    225

    Re: PROBLEM WITH COMBOBOX..important

    Thank you very much , it works fine .

    chris128 , I mensioned already that I am a newbee , and I know it is a simple question for you but believe me I tried to figure it out by myself before I asked , and there are some things that are very urgent , so I'm sorry if the words "urgent" bother you but it is only 2 posts.

    Isn't this forum supposed to help people no matter if they have an easy questions or not ?! or maybe this forum should be called - for advanced only.

    thank you , and I hope for more Patience.

    believe me I'm an engineer and architect and have to give answers for a lot of questions that I find silly.

    Noam.

    Giving an exact answer
    Saves a lot of time!!!

  7. #7
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] PROBLEM WITH COMBOBOX..important

    The word urgent on a free public forum does bother me yes, because it implies that you think your question should be answered before other people's - so tell me, why was it so urgent and important?

    Also, its not that I think people should only ask advanced questions, it is just that asking how to use a basic IF statement is something you learn from any beginners tutorial out there - so I assume you have not followed such a tutorial and will therefore be asking more basic questions like this. Dont you think it would be worth doing one of these tutorials, for your benefit (you wont have to wait for people to answer your questions) and for our benefit (we wont have to repeat what is already readily available in hundreds of tutorials on the web) ? If you are an engineer and an architect then surely you appreciate the importance of understanding the basics before you start trying to do something.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width