Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > simple question about IF CONDITIONS.


Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2010, 05:59 AM
noam309 noam309 is offline
Newcomer
 
Join Date: Aug 2010
Posts: 2
Default simple question about IF CONDITIONS.


Hi ,

I have a question about if conditions - I have this code:

Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If TextBox1.Text = "" Then
            MessageBox.Show("יש להכניס גובה מבנה-קודקוד הגג")
        End If
        If IsNumeric(TextBox1.Text) Then
            If TextBox1.Text > 200 Then
                MessageBox.Show("לפי התקן ניתן לתכנן רק מבנים הנמוכים מ-200 מ")
            End If
        End If
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

        Dim a As Double
        Dim b As Double
        Dim c As Double
        a = TextBox3.Text * Math.Log(TextBox1.Text / TextBox4.Text)

        TextBox7.Text = a

        b = 1 / (1 * Math.Log(TextBox1.Text / TextBox4.Text))
        TextBox8.Text = b

        c = a ^ 2 * 1 ^ 2 * (1 + 2 * 3.5 * b)
        TextBox6.Text = c

    End Sub

It means that I have a combobox and a text box.

If I type a value in the textbox and after that choose a value from the combobox it works just fine, the problem is when I leave this textbox blank -it gives the massgae"יש להכניס גובה מבנה-קודקוד הגג") , and gives an error , I want the code to give me the option to type a value in the textbox and only then to calculate.
I'm sure I was wrong with the position of the condition.

thank for the helpers
Reply With Quote
  #2  
Old 08-01-2010, 06:25 AM
TRSDOSBasic79's Avatar
TRSDOSBasic79 TRSDOSBasic79 is offline
Contributor
 
Join Date: Oct 2003
Location: Pennsylvania
Posts: 422
Default

Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If TextBox1.Text = "" Then
            MessageBox.Show("יש להכניס גובה מבנה-קודקוד הגג")
        End If
this snippet checks for text in the textbox and if it doesn't have any it displays your message. Thats fine , BUT you are still checking for the other conditions. I think you want something like this ...


Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If TextBox1.Text = "" Then
            MessageBox.Show("יש להכניס גובה מבנה-קודקוד הגג")
            Exit Sub
        End If
Reply With Quote
  #3  
Old 08-01-2010, 08:42 AM
noam309 noam309 is offline
Newcomer
 
Join Date: Aug 2010
Posts: 2
Smile Thats it! thank you

Thats it!

THANK YOU

It solve the problem.

Last edited by noam309; 08-01-2010 at 08:48 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->