Touch input coordinates in Visual Basic from T35

I am looking for some VB Code to return XY coordinates of a touch input. So far I have this incomplete code. In debug mode the program crashes when the screen is touched and I don’t know how to handle and trap the event in VB. Any help kindly received.

Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics
Imports Microsoft.SPOT
Imports Microsoft.SPOT.Presentation
Imports Microsoft.SPOT.Presentation.Controls
Imports Microsoft.SPOT.Touch

Partial Public Class Program
    Dim onOff As Boolean = False
    Dim oldVal As Integer
    Dim newVal As Integer
    Dim counter As Integer
    Dim potSetting As Double
    Dim touchX As Integer
    Dim touchY As Integer

    Public Sub ProgramStarted()
        Debug.Print("Program Started")
        Display.WPFWindow.TouchDown = New Microsoft.SPOT.Input.TouchEventHandler(WPFWindow_TouchDown)
        Display.WPFWindow.TouchUp = New Microsoft.SPOT.Input.TouchEventHandler(WPFWindow_TouchUp)

Thanks but no joy.
This is the error shown but I have no experience of using ‘RaiseEvent’.

Public Event TouchDown(sender As Object, e As Microsoft.SPOT.Input.TouchEventArgs)’ is an event, and cannot be called directly. Use a ‘RaiseEvent’ statement to raise an event.

Thanks Andre,
That is the problem I have. I am unsure how to convert the following into VB

  void WPFWindow_TouchUp(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
            display.SimpleGraphics.DisplayText("(" + e.Touches[0].X + "," + e.Touches[0].Y + ")", Resources.GetFont(Resources.FontResources.NinaB),
                Colors.Green, (uint)e.Touches[0].X, (uint)e.Touches[0].Y);
        void WPFWindow_TouchDown(object sender, Microsoft.SPOT.Input.TouchEventArgs e)
            display.SimpleGraphics.DisplayText("(" + e.Touches[0].X + "," + e.Touches[0].Y + ")", Resources.GetFont(Resources.FontResources.NinaB),
                Colors.Red, (uint)e.Touches[0].X, (uint)e.Touches[0].Y);

The display has been named “Display” and is operating correctly with write commands such as:

Display.SimpleGraphics.DisplayRectangle(GT.Color.Red, 1, GT.Color.Red, 10, 10, 50, 50

The only aspect of the display I am unable to access is Inputs. The connections are show as shown here:

Private Sub InitializeModules()
        ' Initialize GTM.Modules and event handlers here.		
        usbClientDP = New GTM.GHIElectronics.UsbClientDP(1)
        Display = New GTM.GHIElectronics.Display_T35(14, 13, 12, 10)

ps The mainboard used is a Fez Spider.

Thanks Andre
I guess we are nearly there but VB doesnt like “object” in:

Private Sub WPFWindow_TouchUp(object sender, Microsoft.SPOT.Input.TouchEventArgs e)

and returns the error: “Keyword is not valid as an identifier”

I’m not sure if this will help as I’m at work and do not have access to try. But when I add an event handler I do it this way…

AddHandler Display.WPFWindow.TouchDown , AddressOf Screen_TouchDown

And then click the red squiggly of the Screen_TouchDown part of the above line and select Create method

1 Like

@ jasuk70 - Thanks very much, that was the code I needed. It looks like the Event is generated by the Display.WPFWindow so is not directly shown in the coding window.

Thanks also to everyone else who commented

@ David G - Hi David, apologies for the direct approach, but would you be willing to share a sample of the final VB code to interact with the touch abilities of the T35 display on VB?

I’ve been trying to follow your previous steps, but seem to have gotten a bit stuck!

Thanks in advance,