Click here to Skip to main content
15,917,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everyone

I have an ASP.NET page with VB, which receives several parameters in the QueryString from an Android application to perform some calculations, for example:

In the code behind the page:
Dim strMedida As String = Request.QueryString("med")
And if I print the value of strMeasure, it shows me the value passed in the request:
Context.Response.Write("La medida es: " & strMedida)
The measure is: 120

But when evaluating the variable with an IF, a SELECT CASE, etc., to do some operation, it doesn't do it. Example:
Dim strRes as String
    Select Case strMedida
        Case "100"
            strRes = "La medida es Sencilla"
        Case "120"
            strRes = "La medida es Semi"
        Case "140"
            strRes = "La medida es Doble"
        Case Else
            strRes = "No hay medida"
    End Select
And if I print the value of strRes, it shows me as if strMeasure had no information. The same happens if I evaluate with Request.QueryString("med"):
No hay medida
Thank you very much for your help

What I have tried:

I have tried creating each parameter of the QueryString as a Class, a Function that returns the value directly and I have not succeeded.

Thank you very much for your help
Updated 24-Jul-23 19:14pm
OriginalGriff 25-Jul-23 0:42am    
This is an English language site, and we can only accept and answer questions in that language.
I have run this through Google Translate to produce a probably-good version, but you should check it and make sure it does say what you are actually asking.

We can't tell: we don't have access to the app generating the data, or the response it gives. And access to the data is essential to work out what is going on.

At a guess, the value returned to your app is not "120", but has either leading or trailing whitespace (Tabs, spaces, and / or newlines) which menas it does not match the compared strings.
I would use Integer.TryParse[^] to convert the string to a number and compare that instead of blindly accepting the string and comparing it!
Share this answer
I agree with @OriginalGriff. You can check by modifying your code:
Context.Response.Write("La medida es: " & strMedida)

Context.Response.Write($"La medida es: [{strMedida}]")

Now you will see the exact value inside the square braces.
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