Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translate this line of code from C# to Visual Baisc

i need some help on one line with translating this code:

Original in C#:

using System.Collections.ObjectModel;
using Microsoft.Maps.MapControl;

namespace Binding_Bing_Map_Control.Modal
{
public class MapModal
{
    public Location MapLocation { get; set; }
    public string TooltipText { get; set; }

    public static ObservableCollection<MapModal> getMapRecords()
    {
        ObservableCollection<MapModal> MapRecords = new ObservableCollection<MapModal>();
        MapRecords.Add(new MapModal() { MapLocation = new Location(47.610015, -122.188362), TooltipText = "Main St, Bellevue, WA 98004" });
        MapRecords.Add(new MapModal() { MapLocation = new Location(47.603562, -122.329496), TooltipText = "James St, Seattle, wa 98104" });
        MapRecords.Add(new MapModal() { MapLocation = new Location(47.609355, -122.189970), TooltipText = "Main St, Bellevue, WA 98004-6405" });
        MapRecords.Add(new MapModal() { MapLocation = new Location(47.615820, -122.238973), TooltipText = "601 76th Ave, Medina ,WA 98039" });
        return MapRecords;
    }
}
}

My translation to VB:

Imports System.Collections.ObjectModel
Imports Microsoft.Maps.MapControl

Namespace Map_Control.Modal

Public Class MapModal

    Public Property Location As WPF.Location
    Public Property TooltipTex As String

    Public Function getMapRecors() As ObservableCollection(Of MapModal)
        Dim MapRecords As New ObservableCollection(Of MapModal)
        MapRecords.Add(New MapModal() {Location = New WPF.Location(47, -122), TooltipTex = "Sample tooltiptext!"})
        Return MapRecords
    End Function

End Class

End Namespace

I get error in line:

MapRecords.Add(New MapModal() {Location = New WPF.Location(47, -122), TooltipTex = "Sample tooltiptext!"})

Error: Value of type Boolean cannot be converted to WindowsApplication1.Map_Control.Modal.MapModal

To clarify what am I doing. I am trying to build wpf application and use bing maps. I am following code from this link., but i am not using Silverlight and i am coding in VB.

like image 958
micco Avatar asked Jun 05 '13 15:06

micco


People also ask

How do I translate a code into another language?

Compilers convert one programming language into another. Usually, compilers are used to convert code so the machine can understand it. If we want it to be human-readable, we need a subset of compilers called transpilers. Transpilers also convert code however the output is generally understandable by a human.

What translates code line by line?

An interpreter translates the code line by line when the program is running.

What is translation in C programming?

In C and C++ programming language terminology, a translation unit (or more casually a compilation unit) is the ultimate input to a C or C++ compiler from which an object file is generated.

Which translator is used in C?

Our C language only support two type translator. Compiler and assembler only. Interpreter come in java language and it always take input as a high level language and convert into machine language.


2 Answers

Try something like this:

MapRecords.Add(New MapModal() With {.Location = New WPF.Location(47, -122), .TooltipTex = "Sample tooltiptext!"})
like image 68
Medinoc Avatar answered Nov 05 '22 09:11

Medinoc


I think the problem is here:

public Location MapLocation { get; set; }

This line can't be translated to

Public Property Location As WPF.Location

I think you're messing with Location class. Notice that there is not such a reference to WPF namespace in the C# version.

like image 34
Oscar Avatar answered Nov 05 '22 08:11

Oscar