Solved

hourly updates not working correctly

Posted on 2008-06-18
1
158 Views
Last Modified: 2013-11-26
I have an application that is in development and there is a form the has 24 text boxes and an update button. the boxes a labled as hours ending. so the first one is labled 00:00:00 the next is 01:00:00 and so on until 23:00:00  so first it checks if it null and if it is it ignores that textbox and if it has a value in it, it write the value and the time of the box. all of them work accept for 01:00:00
any ideas?
Private Sub BtnUpdate_Click(ByVal sender As System.Object, _

                                ByVal e As System.EventArgs) _

                                Handles BtnUpdate.Click

        If (TbxUpdatedMwPrice00.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice00.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice00.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "00:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice00.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice01.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice01.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice01.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "01:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice01.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice02.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice02.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice02.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "02:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice02.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice03.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice03.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice03.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "03:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice03.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice04.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice04.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice04.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "04:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice04.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice05.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice05.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice05.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "05:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice05.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice06.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice06.Text) > MinMWPrice _

                    And Decimal.Parse(TbxUpdatedMwPrice06.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "06:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice06.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice07.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice07.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice07.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "07:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice07.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice08.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice08.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice08.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "08:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice08.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice09.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice09.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice09.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "09:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice09.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice10.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice10.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice10.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "10:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice10.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice11.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice11.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice11.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "11:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice11.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice12.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice12.Text) > MinMWPrice _

                    And Decimal.Parse(TbxUpdatedMwPrice12.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "12:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice12.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice13.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice13.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice13.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "13:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice13.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice14.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice14.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice14.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "14:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice14.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice15.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice15.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice15.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "15:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice15.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice16.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice16.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice16.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "16:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice16.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice17.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice17.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice17.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "17:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice17.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice18.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice18.Text) > MinMWPrice _

                    And Decimal.Parse(TbxUpdatedMwPrice18.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "18:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice18.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice19.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice19.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice19.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "19:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice19.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice20.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice20.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice20.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "20:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice20.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice21.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice21.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice21.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "21:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice21.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice22.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice22.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice22.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "22:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice22.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        If (TbxUpdatedMwPrice23.Text <> "") Then

            If (Decimal.Parse(TbxUpdatedMwPrice23.Text) > MinMWPrice _

            And Decimal.Parse(TbxUpdatedMwPrice23.Text) < MaxMWPrice) Then

                IP21Time = ShortTime & "23:00:00.0"

                SqlStr = "WriteTo_AIDef_fn(" & TbxUpdatedMwPrice23.Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

            End If

        End If

        Call PopulateListView()

        Call ClearTbxMW()

    End Sub

Open in new window

0
Comment
Question by:jlcannon
1 Comment
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 21815982
Try it this way:
    Private Sub BtnUpdate_Click(ByVal sender As System.Object, _

                                ByVal e As System.EventArgs) _

                                Handles BtnUpdate.Click

        Dim matches() As Control

        Dim value As Decimal

        For i As Integer = 0 To 23

            matches = Me.Controls.Find("TbxUpdatedMwPrice" & i.ToString("00"), True)

            If matches.Length > 0 Then

                If Decimal.TryParse(matches(0).Text, value) Then

                    If value > MinMWPrice AndAlso value < MaxMWPrice Then

                        IP21Time = ShortTime & i.ToString("00") & ":00:00.0"

                        SqlStr = "WriteTo_AIDef_fn(" & matches(0).Text & ",'" & IP21Time & "','PLTPOWER$COST')"

                        Call UpdateIP21Tag("USPLQVACOPOWER2", SqlStr)

                    End If

                End If

            End If

        Next

        Call PopulateListView()

        Call ClearTbxMW()

    End Sub

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hovering effect 9 29
Why is "packages element is not declared"? 2 37
Handle null when using linq in this line 1 20
XML & .net 5 18
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now