Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Event Handler using C# and VB.net


  • Please log in to reply
11 replies to this topic

#1 Pinto Novo

Pinto Novo

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationPortugal

Posted 04 October 2011 - 02:02 PM

Hi Stefan I am working in a program that requires the communication between VB.net and C#. I'm using C# to access to Sockets and I'd like to work with the requested string in vb.net. The main ideia is: 1 - An external application send the information via Socket. 2 - The C# program receives the info, and raise an event that can be captured using VB.net. In this step, I can work with the string using vb.net. I send steps and direction for a Step motor. When vb.net stops the motor, send back to C# the response OK/NOT OK. Can you create an example, a simple example that simulates the comunication between VB.net and C# using sockets. The solution has to be one because I need to send both to Netduino Plus! Note: I'm a VB.net Programmer and not C# programmer! :) Thanks at glance! Ricardo

#2 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 04 October 2011 - 02:12 PM

Why exactly do you need to use C# if you know VB.net? It's nice to know both, but it doesn't make sense to mix the two... (And I don't think you CAN mix the two on a Netduino. You can use both, but not in the same application.)

#3 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 04 October 2011 - 02:22 PM

Hi Stefan

Hi :D

You could make a class library in C# and use it in VB.NET like I do in the samples at http://netmftoolbox.codeplex.com/
In some samples (the keypad and rfid reader) I used events.

But that's the only (decent) way to combine both languages I think. If you're going to develop the full package, I don't see a good reason to combine two languages to be honest. It'll only be useful when it's depending on other libraries written in another language.

Does that help?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#4 Pinto Novo

Pinto Novo

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationPortugal

Posted 04 October 2011 - 02:23 PM

Thanks for your concerning! :) Well, What I need is: Send a command line using sockets. VB.net don't have Sockets libs, so I need C# to receive the stream and send back stream. In my project I have a PC that have coordinates - Point A, Point B. My NetDuino calculates the lines between A and B. When it stops C# send to PC the stream OK. If VB.Net had Sockets support, I didn't need C#! :) C# receives a command, and Raise Event that VB.net can capture! Thats the main ideia! Thanks!

#5 Pinto Novo

Pinto Novo

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationPortugal

Posted 04 October 2011 - 02:30 PM

Hi Stefan I think that both projects in kep pad helps me on my project! :) i'll try right way! Thanks to all !

#6 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 04 October 2011 - 06:12 PM

VB.net don't have Sockets libs,

From where did you get that? VB.net supports Sockets! :)
I use it for sending files to my FTP server using a simple Socket FTP client, and the SimpleWebserver also uses Sockets, of course.

I still don't see why you need to use both C# and VB.net. VB.net can also uses handles, events and sockets, so It seems like you are crossing the stream to find water.

#7 Pinto Novo

Pinto Novo

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationPortugal

Posted 04 October 2011 - 07:04 PM

Hi Moskus

Sorry that I didn't express myself correctly!


vb.net supports sockets, but i was refering vb.net for Netduino.


I already tried to add System.Net.Sockets but I didn't have sucess!


If you have a webserver based in vb.net, can you send to me?


Thanks!


Ricardo

#8 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 05 October 2011 - 01:41 PM

vb.net supports sockets, but i was refering vb.net for Netduino.


I was too! VB.net and sockets work great together.:)


Heres a webserver sample using VB.net. I took the C# version and converted it to VB using this web service.


For System.Net.Sockets to work you actually have to import Microsoft.SPOT.Net. I know, it's confusing as hell but that's the way it is.





#9 Pinto Novo

Pinto Novo

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationPortugal

Posted 06 October 2011 - 08:28 AM

Hi Moskus In fact you are right, sockets works in micro framework. And my apps start to work fine, but I have another dought...(hoping that this time the question can be a really question) How can I use mid() function, instr() function? I already add System.Strings, but I can't access to these functions. Thanks at grance! Ricardo

#10 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 06 October 2011 - 08:42 AM

How can I use mid() function, instr() function? I already add System.Strings, but I can't access to these functions.

You're used to VB6 I suppose? Loved those days!!

Try this:
        Dim text As String = "This is a test string"
        Debug.Print(text.Substring(5, 2))            ' "is"
        Debug.Print(text.IndexOf("test").ToString()) ' 10

"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#11 Pinto Novo

Pinto Novo

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationPortugal

Posted 06 October 2011 - 08:48 AM

Thanks for the tip! it work!:) I've read in another post that I can decompile Microsoft.Visualbasic.dll, catch the functions that I need and add these functions to my Microsoft.VisualBasic.dll Microframework... I'll try this! Thanks Ricardo

#12 Moskus

Moskus

    Advanced Member

  • Members
  • PipPipPip
  • 132 posts
  • LocationNorway

Posted 06 October 2011 - 10:27 AM

I've read in another post that I can decompile Microsoft.Visualbasic.dll, catch the functions that I need and add these functions to my Microsoft.VisualBasic.dll Microframework... I'll try this!

If you do this, I'd love to see the code. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.