Add Subscriber with Custom Fields

I have this setup as per the C# example (although i had to convert to VB) but i'm getting this error when trying to run the page...

Compiler Error Message: BC30002: Type 'var' is not defined.

Source Error:

Dim result As var = CampaignMonitorAPIWrapper.Subscriber.AddWithCustomFields(apiKey, listID, txtContactEmail.Text, Name, customFields)

I know you can declare a var in C# but not it which is what I am using so i guess the question is, what is the result, an integer, string or am i missing something?



davidh, 7 years ago


The return type from the wrapper is Result<Integer>, so this should work:

Dim result as Result<Integer> = ...

You can also use inferred typing in VB.NET 2008 (which works the same way as the var keyword in C#), although you need to enable it in the project properties. See these links:


stevied, 7 years ago

Hi Dave,

Thanks for your reply, opted for the following...

Dim result As Result(Of Integer) = CampaignMonitorAPIWrapper.Subscriber.AddWithCustomFields(apiKey, listID, txtContactEmail.Text, FullName, customFields)

Worked just fine.  I think it would be very helpfull to include a VB version in samples.



davidh, 7 years ago

Glad it is working, I see you fixed my incorrect VB generics syntax :-)

While there is no VB.NET sample, there are some places you can use to convert C# to VB:

You can also download an app to convert a whole project if you do a search.

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free