Detect Eject SD card in VB.net
#1
Posted 10 August 2012 - 01:30 AM
Anyone familiar with VB.net can help with some code on how to detect the SD card been ejected?
I am following this topic, but I can do the same in VB.net. Please help and thanks in advance.
Links on how to detect presence of SD card
#2
Posted 10 August 2012 - 01:44 AM
Hi Guys,
Anyone familiar with VB.net can help with some code on how to detect the SD card been ejected?
I am following this topic, but I can do the same in VB.net. Please help and thanks in advance.
Links on how to detect presence of SD card
This code is from Stefan's post converted to VB.
Imports System Imports System.Net Imports System.Net.Sockets Imports System.Threading Imports Microsoft.SPOT Imports Microsoft.SPOT.IO Imports Microsoft.SPOT.Hardware Imports SecretLabs.NETMF.Hardware Imports SecretLabs.NETMF.Hardware.NetduinoPlus Namespace SdCard Public Class Program Public Shared Sub Main() RemovableMedia.Insert += New InsertEventHandler(RemovableMedia_Insert) RemovableMedia.Eject += New EjectEventHandler(RemovableMedia_Eject) Thread.Sleep(Timeout.Infinite) End Sub Private Shared Sub RemovableMedia_Eject(sender As Object, e As MediaEventArgs) Debug.Print("Ejected") End Sub Private Shared Sub RemovableMedia_Insert(sender As Object, e As MediaEventArgs) Debug.Print("Inserted") End Sub End Class End NamespaceI don't have anyway to test here, I am working out of state and staying in a hotel.
Chuck
#3
Posted 10 August 2012 - 06:33 AM
This code is from Stefan's post converted to VB.
I don't have anyway to test here, I am working out of state and staying in a hotel.
Chuck
That code won't work in VB.NET since it works differently with events. This would work:
Module Module1 Sub Main() AddHandler Microsoft.SPOT.IO.RemovableMedia.Eject, AddressOf RemovableMedia_Eject AddHandler Microsoft.SPOT.IO.RemovableMedia.Insert, AddressOf RemovableMedia_Insert Thread.Sleep(Timeout.Infinite) End Sub Sub RemovableMedia_Eject(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs) Debug.Print("Ejected") End Sub Sub RemovableMedia_Insert(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs) Debug.Print("Inserted") End Sub End Module
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#4
Posted 10 August 2012 - 09:49 AM
#5
Posted 10 August 2012 - 10:05 AM
Oh no worries! I like seeing people beeing helpful!I tried to help, but all I could do was to try and convert the code he had. Should have known better.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#6
Posted 11 August 2012 - 08:19 AM
That code won't work in VB.NET since it works differently with events. This would work:
Module Module1 Sub Main() AddHandler Microsoft.SPOT.IO.RemovableMedia.Eject, AddressOf RemovableMedia_Eject AddHandler Microsoft.SPOT.IO.RemovableMedia.Insert, AddressOf RemovableMedia_Insert Thread.Sleep(Timeout.Infinite) End Sub Sub RemovableMedia_Eject(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs) Debug.Print("Ejected") End Sub Sub RemovableMedia_Insert(sender As Object, e As Microsoft.SPOT.IO.MediaEventArgs) Debug.Print("Inserted") End Sub End Module
Hi Carb & Stefan,
Thank you for your great helps.
Cheers!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users