VB.net Wrong format when sending DateTimePicker

2

I am doing a program in .Net , to automate the loading of data in a web page (which I can not modify the code).

The problem happens when I send the date to the web. As you can see in the following code, you should send the date in the format dd / MM / yyyy (which is the format accepted by the web), but instead send the format dd-MM-yyyy (with "-" instead of "/").

 fecha = Form1.DateTimePicker1.Value.ToString("dd/MM/yyyy")
        WebBrowser1.Document.GetElementById("Fecha").InnerText = (fecha)
        WebBrowser1.AllowNavigation = True
        WebBrowser1.Document.Forms(0).InvokeMember("submit")

As an extra data, if I show the variable "date" in a messagebox, it is displayed in the correct format. Thank you very much

    
asked by Cristian Raña 27.05.2016 в 18:12
source

1 answer

-1

Pass the CultureInfo.InvariantCulture as the second parameter, and it will return the format you give it even if it is a special character:

Form1.DateTimePicker1.Value.ToString("dd/MM/yyyy", Globalization.CultureInfo.InvariantCulture )
    
answered by 27.05.2016 / 21:00
source