Click here to Skip to main content
15,899,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
Please help me to get correct answer.
I Am using Combo box to change the value on particular record as GeneralWard, ICU, Room. But the textbox22 value was changed in Once
in second time it was not changed second time.
I am using
ComboBox as PatientID
TextBox1 as No. of Days by Calculating Days
TextBox22 as FinallBill
TextBox16 as GeneralWard
TextBox15 as Doctor Fee
TextBox14 as Sister Charges

the code is as
follows
Thanks in advance for giving solution

What I have tried:

Private Sub TextBox13_TextChanged(sender As Object, e As EventArgs) Handles TextBox13.TextChanged
        Dim calc As Integer
        Dim tot As Integer
        Try

            If TextBox13.Text = "General Ward" Then
                s = Val(Me.TextBox1.Text)
                Me.TextBox16.Text = gm
                Me.TextBox15.Text = dr
                Me.TextBox14.Text = nr

                calc = (Val(Me.TextBox14.Text) + Val(Me.TextBox15.Text) + Val(Me.TextBox16.Text) + Val(Me.TextBox17.Text))
                tot = calc * s
            ElseIf TextBox13.Text = "ICU" Then
                s = Val(Me.TextBox1.Text)
                Me.TextBox16.Text = icu
                Me.TextBox15.Text = dr
                Me.TextBox14.Text = nr

                calc = (Val(Me.TextBox14.Text) + Val(Me.TextBox15.Text) + Val(Me.TextBox16.Text) + Val(Me.TextBox17.Text))
                tot = calc * s
            ElseIf TextBox13.Text = "Room" Then
                s = Val(Me.TextBox1.Text)
                Me.TextBox16.Text = rm
                Me.TextBox15.Text = dr
                Me.TextBox14.Text = nr

                calc = (Val(Me.TextBox14.Text) + Val(Me.TextBox15.Text) + Val(Me.TextBox16.Text) + Val(Me.TextBox17.Text))
                tot = calc * s
            End If
            TextBox22.Text = tot

        Catch ex As Exception
            MsgBox("ERROR : " & ex.Message.ToString)
        End Try
    End Sub
Posted
Updated 20-Nov-18 3:48am

1 solution

The code you show will only change Textbox 22 if TextBox13 changes: unless that happens the event handler is not called.
So start with the debugger and make sure that the event handler is firing when you expect it to.

It's quite possible that this is all down to your use of default names for everything: it';s too easy to use the wrong text box somewhere and not notice. Do yourself a favour, and stop using Visual Studio default names for everything - you may remember that "TextBox8" is the mobile number today, but when you have to modify it in three weeks time, will you then? Use descriptive names - "tbMobileNo" for example - and your code becomes easier to read, more self documenting, easier to maintain - and surprisingly quicker to code because Intellisense can get to to "tbMobile" in three keystrokes, where "TextBox8" takes thinking about and 8 keystrokes...

Having at least 22 textboxes on the same form sounds like a problem to start with, but using the default names for them as well is just asking for maintenance problems.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900