I need help with this code using Visual Basic.net

easyeman

Active member
Joined
Nov 16, 2005
Messages
28
Location
Decatur, AL
Programming Experience
1-3
I am doing web programming on a web site, and basically what I am doing is having a file so you can select sizes from a drop down menu and the code will cause the selected choice to bring up the correct size in the database system we have. I am doing this program using Visual Web Developer and it is Visual Basic.net code, so I figured this was the right place.

I can clarify more if I need to, but basically I have these fire adapters I'm putting on the web, and I can't get the code to work right (I use the same thing for a couple items, and one works and one doesn't, so not sure what's going on).

Anyway, it's set up like this: you choose the two adapter sizes, such as "1.0FNST" and "1.5FNST", and the part number after you chose would appear like this: "35R10FNST15FNST", so it'll have the starting number, and then add the two choices you select from a drop-down menu.

That's what it should do, however, when I put in the code, it keeps adding a letter into the second part so it will not work...so it ends up being "35R10FNST15FFNST" < adds an extra F in there for some reason. I cannot figure out how to remove it.

That's where I need someone's help. I'd like anyone to look it over and maybe figure out what's going on or if you see the error in the code. It's driving me crazy and I've updated it a few times and still get nothing and it has the same problem.

I appreciate any help and will give more info as to what I'm trying to do if people need it. Here is the code:

VB.NET:
                Case "35RXX"
                    Select Case Left(Option1, 3)
                        Case ".75"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0", "2.5"
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "1.0"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0", "2.5"
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "1.5"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0", "2.5", "3.0"
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "2.0"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0", "2.5", "3.0"
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "2.5"
                            Option1 = Option1.Replace(".", "")
                            Option2 = Option2.Replace(".", "")
                            NewDetails.NewProductID = "35R" & Option1 & Option2
                        Case "3.0"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "3.5"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "4.0"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "4.5"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "5.0"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "6.0"
                            Select Case Left(Option2, 3)
                                Case ".75", "1.0", "1.5", "2.0"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    Option1 = Option1.Replace(".", "")
                                    Option2 = Option2.Replace(".", "")
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                    End Select
 
Nevermind, I finally got it working. Basically nothing was actually wrong with the code since it should work, but I guess the last update did not work, since when it was updated again with that code, the sizing worked haha, so everything is fine.

However, I am having another problem that I need to fix and get working. Basically how this works is that option1(left selection) can not be larger than option2(right selection)...if it is then the choices need to be switched and shown as that number. For example, if you select 6.0 FNST(1st) and 2.5 FNST(2nd) as options, then when it goes through it should bring back 35R25FNST60FNST for the part number...as you can see it switched the two choices automatically so the left one is the lower number. I have changed the code some and added the if statement, but it is not working so maybe I'm just overlooking something.

I'll repost the code below so you can all see it, but if someone can help then I'd appreciate it. The code is actually working as far as getting it and not adding a letter, but I just need to get the options switch under that one condition. Otherwise it will stay just as it is with options selected. Thanks in advance!

VB.NET:
Case "35RXX"
                    Option1 = Option1.Replace(".", "")
                    Option2 = Option2.Replace(".", "")
                    If Left(Option1, 2) > Left(Option2, 2) Then
                        Dim NewOption1 As String = Option2
                        Dim NewOption2 As String = Option1
                        Option1 = NewOption1
                        Option2 = NewOption2
                    End If

                    Select Case Left(Option1, 2)
                        Case "75"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20", "25"
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "10"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20", "25"
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "15"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20", "25", "30"
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "20"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20", "25", "30"
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                                Case Else
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                            End Select
                        Case "25"
                            NewDetails.NewProductID = "35R" & Option1 & Option2
                        Case "30"
                            Select Case Left(Option2, 2)
                                Case "75", "10"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "35"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "40"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "45"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "50"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                        Case "60"
                            Select Case Left(Option2, 2)
                                Case "75", "10", "15", "20"
                                    NewDetails.NewProductID = "NOT AVAILABLE"
                                Case Else
                                    NewDetails.NewProductID = "35R" & Option1 & Option2
                            End Select
                    End Select
 
Back
Top