none
Traduccion de codigo C# a VB

    Pregunta

  • Buenas tardes, necesitaría poder traducir un código C# a VB, el código es el siguiente:

     public string CreaRegistro()
            {
                UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    new ClientSecrets
                    {
                        ClientId = "XXXX",
                        ClientSecret = "XXXX",
                    },
                    new[] { CalendarService.Scope.Calendar },
                    "user",
                    CancellationToken.None).Result;
    
                // Create the service.
                var service = new CalendarService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName = "Windows",
                });
    
    
                // Define parameters of request.
    
    
                Event NewEvent = new Event()
                {
                    Summary = "YA VOREM",
                    Location = "Prueba Location",
                    Description = "Piscina con Celia",
                    Start = new EventDateTime()
                    {
                        DateTime = DateTime.Parse("2016-09-08T08:00:00-07:00"),
                    },
                    End = new EventDateTime()
                    {
                        DateTime = DateTime.Parse("2016-09-08T09:00:00-07:00"),
                    }
                   
                   
                };
    
    
    
                EventsResource.InsertRequest request2 = service.Events.Insert(NewEvent,"primary");
                Event createdevent = request2.Execute();
           
                return createdevent.Id;
            }

    Lo he intentado con varias herramientas para traducir código, pero no me funciona.

    Les agradecería mucho vuestra ayuda.

    Un saludo

    jueves, 8 de septiembre de 2016 16:12

Respuestas

  • Hola Vicdeju

    Prueba así:

    Public Function CreaRegistro() As String
    	Dim credential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With { _
    		Key .ClientId = "XXXX", _
    		Key .ClientSecret = "XXXX" _
    	}, New () {CalendarService.Scope.Calendar}, "user", CancellationToken.None).Result
    
    	' Create the service.
    	Dim service = New CalendarService(New BaseClientService.Initializer() With { _
    		Key .HttpClientInitializer = credential, _
    		Key .ApplicationName = "Windows" _
    	})
    
    
    	' Define parameters of request.
    
    
    
    
    	Dim NewEvent As New [Event]() With { _
    		Key .Summary = "YA VOREM", _
    		Key .Location = "Prueba Location", _
    		Key .Description = "Piscina con Celia", _
    		Key .Start = New EventDateTime() With { _
    			Key .DateTime = DateTime.Parse("2016-09-08T08:00:00-07:00") _
    		}, _
    		Key .[End] = New EventDateTime() With { _
    			Key .DateTime = DateTime.Parse("2016-09-08T09:00:00-07:00") _
    		} _
    	}
    
    
    
    	Dim request2 As EventsResource.InsertRequest = service.Events.Insert(NewEvent, "primary")
    	Dim createdevent As [Event] = request2.Execute()
    
    	Return createdevent.Id
    End Function

    Saludos y suerte!

     

    Javier

    • Marcado como respuesta Vicdeju jueves, 8 de septiembre de 2016 17:06
    jueves, 8 de septiembre de 2016 16:42

Todas las respuestas

  • Hola Vicdeju

    Prueba así:

    Public Function CreaRegistro() As String
    	Dim credential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With { _
    		Key .ClientId = "XXXX", _
    		Key .ClientSecret = "XXXX" _
    	}, New () {CalendarService.Scope.Calendar}, "user", CancellationToken.None).Result
    
    	' Create the service.
    	Dim service = New CalendarService(New BaseClientService.Initializer() With { _
    		Key .HttpClientInitializer = credential, _
    		Key .ApplicationName = "Windows" _
    	})
    
    
    	' Define parameters of request.
    
    
    
    
    	Dim NewEvent As New [Event]() With { _
    		Key .Summary = "YA VOREM", _
    		Key .Location = "Prueba Location", _
    		Key .Description = "Piscina con Celia", _
    		Key .Start = New EventDateTime() With { _
    			Key .DateTime = DateTime.Parse("2016-09-08T08:00:00-07:00") _
    		}, _
    		Key .[End] = New EventDateTime() With { _
    			Key .DateTime = DateTime.Parse("2016-09-08T09:00:00-07:00") _
    		} _
    	}
    
    
    
    	Dim request2 As EventsResource.InsertRequest = service.Events.Insert(NewEvent, "primary")
    	Dim createdevent As [Event] = request2.Execute()
    
    	Return createdevent.Id
    End Function

    Saludos y suerte!

     

    Javier

    • Marcado como respuesta Vicdeju jueves, 8 de septiembre de 2016 17:06
    jueves, 8 de septiembre de 2016 16:42
  • Muchas gracias Javier.
    jueves, 8 de septiembre de 2016 17:05