-1

How i do to custom a url with parameters ? In my example i have 3 parameters

Textbox1.Text = "Ikea"
Textbox2.Text = "Table"
Textbox3.Text = "Black"

The final url is need to be like:

https://localhost/objects?color=Black&manufacturer=Ikea&type=Table

in Textbox4.Text.

So how i do to add the previous values of the previous Textbox ? Currently i have that :

Private Sub FinalScrapper_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    TextBox1.Text = "Ikea"
    TextBox2.Text = "Table"
    TextBox3.Text = "Black"

    TextBox4.Text = ("https://localhost/objects?color=Black&manufacturer=Ikea&type=Table")
    'The correct parameters are something like that ?
    'TextBox4.Text = ("https://localhost/objects?color=TextBox3.Text&manufacturer=TextBox1.Text&type=TextBox2.Text")
End Sub

Thanks you.

Manada
  • 61
  • 9
  • Take a look at: [String.Concat Method](https://learn.microsoft.com/en-us/dotnet/api/system.string.concat?view=netframework-4.8) – JayV Sep 28 '19 at 19:28
  • Or [Interpolated Strings (Visual Basic Reference)](https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/strings/interpolated-strings) – JayV Sep 28 '19 at 19:29
  • The most basic way to concatenate strings in VB is `"string1" & "string2"` or `stringVar1 & stringVar2` (you can also use `+` instead of `&` as a string concatenation operator). _That_ you need to know, although it's not the best choice for this particular case. What JayV has suggested is more appropriate. I would go with Interpolated strings for this situation (or [`String.Format()`](https://learn.microsoft.com/en-us/dotnet/api/system.string.format) if you're using an old version of VB). – 41686d6564 stands w. Palestine Sep 28 '19 at 19:35
  • Thanks you for the tips. – Manada Sep 28 '19 at 19:52
  • Possible duplicate of [How to build a query string for a URL in C#?](https://stackoverflow.com/questions/829080/how-to-build-a-query-string-for-a-url-in-c) – Andrew Morton Sep 28 '19 at 21:23

1 Answers1

1

I used Interpolated Strings as suggested in the comments and the following worked for me:

Private Sub FinalScrapper_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    TextBox1.Text = "Ikea"
    TextBox2.Text = "Table"
    TextBox3.Text = "Black"

    Dim manufacturer = TextBox1.Text
    Dim type = TextBox2.Text
    Dim color = TextBox3.Text

    Dim s1 = $"https://localhost/objects?color={color}&manufacturer={manufacturer}&type={type}"
    TextBox4.Text = s1
End Sub
Manada
  • 61
  • 9