0
votes

I have been trying to get the following Barcode reader program working on a windows phone.

I have followed the steps on the following website : http://developer.nokia.com/community/wiki/Generating_and_scanning_barcodes_using_ZXing_on_Windows_Phone

and have converted it to vb.net but there is one line of code that seems to be giving me trouble.

The example on the site uses c# and the following block of code is the one I`m having trouble with

// This timer will be used to scan the camera buffer every 250ms and scan for any barcodes
    _scanTimer = new DispatcherTimer();
    _scanTimer.Interval = TimeSpan.FromMilliseconds(250);
    _scanTimer.Tick += (o, arg) => ScanForBarcode();

when this is converted to vb.net you get the following

' This timer will be used to scan the camera buffer every 250ms and scan for any barcodes
_scanTimer = New DispatcherTimer()
_scanTimer.Interval = TimeSpan.FromMilliseconds(250)
_scanTimer.Tick += Function(o, arg) ScanForBarcode()

I am getting two errors both on the last line:

  1. Public Event Tick(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

if I add the RaiseEvent to the beginning of the line I then get the following error

_scanTimer' is not an event of 'PhoneApp2.Scan'

  1. the ScanForBarcode() event produces the following error : Expression does not produce a value.

Any help on the above errors would be much appreciated as I am not sure what to do to rectify the errors.

Thanks Gareth

1

1 Answers

1
votes

Try this:

AddHandler _scanTimer.Tick, Sub(o As Object, arg As EventArgs)
                               ScanForBarcode()
                            End Sub

Or to shorten it even more:

AddHandler _scanTimer.Tick, Sub(o As Object, arg As EventArgs) ScanForBarcode()

Events are added using a different pattern in vb.net.