Stragomagus Posted April 6, 2009 Share Posted April 6, 2009 I'm having some bleeding issues with some code in in a web application, the code that is causing the problem is bold tags around it. Everytime I run the app the "chkancient.checked = true" and the "cdbl(ddlnights.selectedvalue) > 3", when checked, result in the "> 3" always being doubled more than the equation calls for. Any help in to solving this issue would be of great help. Partial Class _Default Inherits System.Web.UI.Page 'This section here declares the variables for the rooms and their additional fees for 'extra nights Dim decinsidecost As Decimal = 399D Dim decinsideextracost As Decimal = 109D Dim decoceancost As Decimal = 699D Dim decoceanextracost As Decimal = 159D Dim decancientcost As Decimal = 179D -------------------------------------------- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub --------------------------------------------- rotected Sub txtname_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtname.TextChanged End Sub --------------------------- Protected Sub ddlnights_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlnights.SelectedIndexChanged End Sub ---------------------------------- Protected Sub chkancient_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkancient.CheckedChanged End Sub ------------------------------------- Protected Sub cldbeginning_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cldbeginning.SelectionChanged End Sub ---------------------------------------------------------- Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click 'The btnsubmit event checks for and calculates all chosen items as well as any 'additional fees. Dim strname As String Dim strmessage As String Dim decroomcost As Decimal = 0D Dim intnights As Integer Dim decswitchvariable As Decimal strname = txtname.Text.Trim Lblmessage.Text = "" If Not (Chkinsidestate.Checked Or Chkocean.Checked) Then Lblroomerror.Visible = True If cldbeginning.SelectedDate < cldbeginning.TodaysDate Then lbldateerror.Visible = True Else lbldateerror.Visible = False End If Else Lblroomerror.Visible = False If cldbeginning.SelectedDate >= cldbeginning.TodaysDate Then lbldateerror.Visible = False If Chkinsidestate.Checked Then decroomcost += decinsidecost decswitchvariable = decinsideextracost End If If Chkocean.Checked Then decroomcost += decoceancost decswitchvariable = decoceanextracost End If intnights = Convert.ToInt32(ddlnights.SelectedItem.Text) decroomcost = decroomcost If CDbl(ddlnights.SelectedValue) > 3 Then decroomcost = decroomcost + ((intnights - 3) * decswitchvariable) End If If chkancient.Checked = True Then decroomcost = decroomcost + decancientcost End If [b]If CDbl(ddlnights.SelectedValue) > 3 And chkancient.Checked = True Then decroomcost = decroomcost + decancientcost + ((intnights - 3) * decswitchvariable)[/b] End If strmessage = "A reservation has been made for: " & " " & strname & " " strmessage &= "The room(s) cost is: " & decroomcost.ToString("C") & " " strmessage &= "Arrival date " & cldbeginning.SelectedDate.ToShortDateString() & " " & " for " & intnights & " night(s)" Lblmessage.Text = strmessage Else lbldateerror.Visible = True End If End If End Sub End Class Quote - Revenge is such a nasty thing that only breeds more vengeful souls, but in some situations revenge does not even need to be sought out, but only bided. Link to comment Share on other sites More sharing options...
JoeDaStudd Posted April 6, 2009 Share Posted April 6, 2009 Zip the project up and send them to me ([email protected]). I'm having trouble understanding it as I can't see CDbl as being defined. [hide=Drops]Dragon Axe x11Berserker Ring x9Warrior Ring x8SeercullDragon MedDragon Boots x4 - all less then 30 kcGodsword Shard (bandos)Granite Maul x 3Solo only - doesn't include barrows[/hide][hide=Stats][/hide] Link to comment Share on other sites More sharing options...
Stragomagus Posted April 6, 2009 Author Share Posted April 6, 2009 Included all the rest of the code for you. At first I had the CDBL written differently, but visual basic's "help you along" program wouldn't let me write it any other way for the drop down list, so no it isn't defined at all and shouldn't have to be if I was forced to write it that way. *problem solved* just a case of erasing the "Cdbl"(stupid helping program caused that one). Quote - Revenge is such a nasty thing that only breeds more vengeful souls, but in some situations revenge does not even need to be sought out, but only bided. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now