Conversion from C# to VB

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

30 Replies - 1199 Views - Last Post: 04 March 2012 - 08:22 PM Rate Topic: -----

#1 flyj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-March 12

Conversion from C# to VB

Posted 03 March 2012 - 01:23 PM

Hello All,

Please i need help trying to make sense of this. It just doesn't seem to work for me. Thanks in advance for reading through and responding.


'Equals Expected


Private Sub LoadSalesRepSales(lastName As String)

            Try
                Dim reader As New CSVReader()
				Dim result = From s In reader.GetSales()
				             Join c In reader.GetSalesRep() 
				            [b] On s.SalesRepID = c.SalesRepIDOrder By c.SalesRepIDNew With { _[/b]
					Key .SalesRepID = c.SalesRepID, _
					Key .FirstName = c.FirstName, _
					Key .LastName = c.LastName, _
					Key .PhotoFile = c.PhotoFile, _
					Key .Manufacturer = s.Manufacturer, _
					Key .Model = s.Model, _
					Key .Color = s.Color, _
					Key .Year = s.Year, _
					Key .DateSold = s.DateSold, _
					Key .AcquisitionCost = s.AcquisitionCost, _
					Key .MaintenanceCost = s.MaintenanceCost, _
					Key .SellingPrice = s.SellingPrice, _
					Key .AquiredDate = s.AquiredDate, _
					Key .OdometerReading = s.OdometerReading, _
					Key .StartDate = c.StartDate, _
					Key .VehicleID = s.VehicleID _
				}


View Postflyj, on 03 March 2012 - 01:20 PM, said:

Hello All,

Please i need help trying to make sense of this. It just doesn't seem to work for me. Thanks in advance for reading through and responding.


'Equals Expected


Private Sub LoadSalesRepSales(lastName As String)

            Try
                Dim reader As New CSVReader()
				Dim result = From s In reader.GetSales()
				             Join c In reader.GetSalesRep() 
				            [b] On s.SalesRepID = c.SalesRepIDOrder By c.SalesRepIDNew With { _[/b]
					Key .SalesRepID = c.SalesRepID, _
					Key .FirstName = c.FirstName, _
					Key .LastName = c.LastName, _
					Key .PhotoFile = c.PhotoFile, _
					Key .Manufacturer = s.Manufacturer, _
					Key .Model = s.Model, _
					Key .Color = s.Color, _
					Key .Year = s.Year, _
					Key .DateSold = s.DateSold, _
					Key .AcquisitionCost = s.AcquisitionCost, _
					Key .MaintenanceCost = s.MaintenanceCost, _
					Key .SellingPrice = s.SellingPrice, _
					Key .AquiredDate = s.AquiredDate, _
					Key .OdometerReading = s.OdometerReading, _
					Key .StartDate = c.StartDate, _
					Key .VehicleID = s.VehicleID _
				}




The Error is :

Equals Expected in

 Join c In reader.GetSalesRep() 
				             On s.SalesRepID = c.SalesRepIDOrder By c.SalesRepIDNew With {
_


Is This A Good Question/Topic? 0
  • +

Replies To: Conversion from C# to VB

#2 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Conversion from C# to VB

Posted 03 March 2012 - 01:23 PM

Did you convert this using a converter?
I'm not quite sure whether those curly braces should be there. I might be wrong but haven't seen code like this before. In VB.NET, With statements always end with well.... End With at the end.

This post has been edited by nK0de: 03 March 2012 - 01:34 PM

Was This Post Helpful? 0
  • +
  • -

#3 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Conversion from C# to VB

Posted 03 March 2012 - 01:29 PM

Your title says conversion from C# to VB.Net - where's the original? Did you run this through a converter or did you attempt it yourself?
I've used this on occasion: http://www.developer...t/csharp-to-vb/
Was This Post Helpful? 0
  • +
  • -

#4 flyj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-March 12

Re: Conversion from C# to VB

Posted 03 March 2012 - 01:47 PM

View PostnK0de, on 03 March 2012 - 01:23 PM, said:

Did you convert this using a converter?
I'm not quite sure whether those curly braces should be there. I might be wrong but haven't seen code like this before. In VB.NET, With statements always end with well.... End With at the end.



Yes i converted using a converter.

View PostDimitriV, on 03 March 2012 - 01:29 PM, said:

Your title says conversion from C# to VB.Net - where's the original? Did you run this through a converter or did you attempt it yourself?
I've used this on occasion: http://www.developer...t/csharp-to-vb/



Yes,i ran it through a converter.

Telrik n Developer fusion
Was This Post Helpful? 0
  • +
  • -

#5 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Conversion from C# to VB

Posted 03 March 2012 - 01:51 PM

Also I think it needs to be Private Sub LoadSalesRepSales(ByVal lastName As String)
Was This Post Helpful? 0
  • +
  • -

#6 flyj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-March 12

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:00 PM

View PostDimitriV, on 03 March 2012 - 01:51 PM, said:

Also I think it needs to be Private Sub LoadSalesRepSales(ByVal lastName As String)



Thanks for that...i just included that. I still can't get rid of the

'Equals Expected'

Error
Was This Post Helpful? 0
  • +
  • -

#7 CodingSup3rnatur@l-360  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 992
  • View blog
  • Posts: 972
  • Joined: 30-September 10

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:00 PM

I think you probably want something more like this:

        Dim result = From s In reader.GetSales()
                     Join c In reader.GetSalesRep()
                     On s.SalesRepID Equals c.SalesRepID
                     Order By c.SalesRepID
                     Select New With { _
                                         Key .SalesRepID = c.SalesRepID, _
                                         Key .FirstName = c.FirstName, _
                                         Key .LastName = c.LastName, _
                                         Key .PhotoFile = c.PhotoFile, _
                                         Key .Manufacturer = s.Manufacturer, _
                                         Key .Model = s.Model, _
                                         Key .Color = s.Color, _
                                         Key .Year = s.Year, _
                                         Key .DateSold = s.DateSold, _
                                         Key .AcquisitionCost = s.AcquisitionCost, _
                                         Key .MaintenanceCost = s.MaintenanceCost, _
                                         Key .SellingPrice = s.SellingPrice, _
                                         Key .AquiredDate = s.AquiredDate, _
                                         Key .OdometerReading = s.OdometerReading, _
                                         Key .StartDate = c.StartDate, _
                                         Key .VehicleID = s.VehicleID _
                                      }



I have replaced s.SalesRepID = c.SalesRepID with s.SalesRepID Equals c.SalesRepID, and fixed some small formatting issues :)

This post has been edited by CodingSup3rnatur@l-360: 03 March 2012 - 02:11 PM

Was This Post Helpful? 0
  • +
  • -

#8 flyj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-March 12

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:24 PM

View PostCodingSup3rnatur@l-360, on 03 March 2012 - 02:00 PM, said:

I think you probably want something more like this:

        Dim result = From s In reader.GetSales()
                     Join c In reader.GetSalesRep()
                     On s.SalesRepID Equals c.SalesRepID
                     Order By c.SalesRepID
                     Select New With { _
                                         Key .SalesRepID = c.SalesRepID, _
                                         Key .FirstName = c.FirstName, _
                                         Key .LastName = c.LastName, _
                                         Key .PhotoFile = c.PhotoFile, _
                                         Key .Manufacturer = s.Manufacturer, _
                                         Key .Model = s.Model, _
                                         Key .Color = s.Color, _
                                         Key .Year = s.Year, _
                                         Key .DateSold = s.DateSold, _
                                         Key .AcquisitionCost = s.AcquisitionCost, _
                                         Key .MaintenanceCost = s.MaintenanceCost, _
                                         Key .SellingPrice = s.SellingPrice, _
                                         Key .AquiredDate = s.AquiredDate, _
                                         Key .OdometerReading = s.OdometerReading, _
                                         Key .StartDate = c.StartDate, _
                                         Key .VehicleID = s.VehicleID _
                                      }



I have replaced s.SalesRepID = c.SalesRepID with s.SalesRepID Equals c.SalesRepID, and fixed some small formatting issues :)



Thanks a bunch. It worked. However, it gives me this Error :

'FirstName' is not a member of 'Integer'
'LastName' is not a member of 'String'


Try
				Dim reader As New CSVReader()
                Dim result = From s In reader.GetSales()
                             Join c In reader.GetSalesRep()
                             On s.SalesRepID Equals c.SalesRepID
                Order By c.SalesRepID
                             Select New _
                With { _
                    .SalesRepID = c.SalesRepID _
                     .FirstName = c.FirstName _
                    .LastName = c.LastName _
                    .PhotoFile = c.PhotoFile _

Was This Post Helpful? 0
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,479
  • Joined: 29-May 08

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:34 PM

With can be use in a similar but different context of Object Initialisers (MSDN).

This post has been edited by AdamSpeight2008: 03 March 2012 - 02:40 PM

Was This Post Helpful? 1
  • +
  • -

#10 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 584
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:36 PM

With What though? I thought With was to access an object and all of its members.
Was This Post Helpful? 0
  • +
  • -

#11 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,479
  • Joined: 29-May 08

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:43 PM

Object Initialisers have no End With they're enclosed inside squiggly braces { }

This post has been edited by AdamSpeight2008: 03 March 2012 - 02:47 PM

Was This Post Helpful? 0
  • +
  • -

#12 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:49 PM

learn something new everyday. :) Thanks AdamSpeight2008
Was This Post Helpful? 0
  • +
  • -

#13 flyj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-March 12

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:50 PM

View PostAdamSpeight2008, on 03 March 2012 - 02:43 PM, said:

Object Initialisers have no End With they're enclosed inside squiggly braces { }



Oh i ended the With statement with

}

Sorry if i don't make lots of sense. I am pretty new at this.
But it still gives me this error :

'FirstName' is not a member of 'Integer'
'LastName' is not a member of 'String'



Try
				Dim reader As New CSVReader()
                Dim result = From s In reader.GetSales()
                             Join c In reader.GetSalesRep()
                             On s.SalesRepID Equals c.SalesRepID
                Order By c.SalesRepID
                             Select New _
                With { _
                    .SalesRepID = c.SalesRepID _
                     .FirstName = c.FirstName _
                    .LastName = c.LastName _
                    .PhotoFile = c.PhotoFile _
                    .Manufacturer = s.Manufacturer _
                    .Model = s.Model _
                    .Color = s.Color _
                    .Year = s.Year _
                    .DateSold = s.DateSold _
                    .AcquisitionCost = s.AcquisitionCost _
                    .MaintenanceCost = s.MaintenanceCost _
                    .SellingPrice = s.SellingPrice _
                    .AquiredDate = s.AquiredDate _
                    .OdometerReading = s.OdometerReading _
                    .StartDate = c.StartDate _
       .VehicleID = s.VehicleID _
                }

Was This Post Helpful? 0
  • +
  • -

#14 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,479
  • Joined: 29-May 08

Re: Conversion from C# to VB

Posted 03 March 2012 - 02:55 PM

Where are your commas? Look at the MSDN article in linked to.

DimitriV:= vb.net has a lot of contextual keywords.

Where to get the vb.net grammar
Was This Post Helpful? 0
  • +
  • -

#15 flyj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-March 12

Re: Conversion from C# to VB

Posted 03 March 2012 - 03:01 PM

View PostAdamSpeight2008, on 03 March 2012 - 02:55 PM, said:

Where are your commas? Look at the MSDN article in linked to.

DimitriV:= vb.net has a lot of contextual keywords.

Where to get the vb.net grammar



Thanks a bunch...oversight on my part.I am just pretty new at this and not familiar with a lot of things.

It cleared up all the errors but i have the :

Expression Expected Error For

 .VehicleID = s.VehicleID,
                }

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3