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 VB.net which is what I am using so i guess the question is, what is the result, an integer, string or am i missing something?

Regards,

Stephen

davidh, 8 years ago

Hi,

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:

http://msmvps.com/blogs/deborahk/archive/2009/07/28/inferred-typing.aspx
http://visualbasic.about.com/b/2008/02/16/option-infer-in-vbnet-2008.htm

Dave

stevied, 8 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.

Regards,

S

davidh, 8 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:

http://www.kamalpatel.net/ConvertCSharp2VB.aspx
http://www.developerfusion.com/tools/convert/csharp-to-vb/

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

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free