5 Replies - 5207 Views - Last Post: 23 July 2009 - 06:25 AM

#1 fizarah.parveen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-July 09

Making a Phone Vibrate using VB.NET

Posted 16 July 2009 - 10:57 PM

Hi.. we are doing an game for our assignment.. we would want to know how to make a phone vibrate when the result turns win or lose.. and we also want to know if there is a way to set the backlight turn off or on (within the game)..

Could anybody help us with this.. by the way.. we are doing this program in vb.net..

Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Making a Phone Vibrate using VB.NET

#2 Mezius  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 72
  • Joined: 13-April 09

Re: Making a Phone Vibrate using VB.NET

Posted 20 July 2009 - 10:15 AM

Assuming you are using windows mobile, since it's VB.net.
It's fairly easy to make it work, the hard part was finding the actual API.
Windows mobile 5/6 vibration was moved to the LED API which makes it obscure to find.
The code I use in my app is this
    Private Structure NLED_SETTINGS_INFO
        Public LedNum As Integer
        Public OffOnBlink As Integer
        Public TotalCycleTime As Integer
        Public OnTime As Integer
        Public OffTime As Integer
        Public MetaCycleOn As Integer
        Public MetaCycleOff As Integer
    End Structure

    <DllImport("Coredll")> _
    Private Shared Function NLedSetDevice(ByVal deviceId As Integer, ByRef info As NLED_SETTINGS_INFO) As Boolean
    End Function

    Private Shared Sub SetVibrate(ByVal state As Boolean)
        Dim info As New NLED_SETTINGS_INFO()
        info.LedNum = 1
        info.OffOnBlink = If(state, 1, 0)
        NLedSetDevice(1, info)
    End Sub



On most devices the vibration is set to LED device 1.
For more information on the API go here http://msdn.microsof...y/ms923732.aspx

As for turning off the backlight, that's easy as well.
Information on it can be found here http://msdn.microsof...y/aa455153.aspx
Was This Post Helpful? 1
  • +
  • -

#3 fizarah.parveen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-July 09

Re: Making a Phone Vibrate using VB.NET

Posted 21 July 2009 - 12:57 AM

View PostMezius, on 20 Jul, 2009 - 09:15 AM, said:

Assuming you are using windows mobile, since it's VB.net.
It's fairly easy to make it work, the hard part was finding the actual API.
Windows mobile 5/6 vibration was moved to the LED API which makes it obscure to find.
The code I use in my app is this
    Private Structure NLED_SETTINGS_INFO
        Public LedNum As Integer
        Public OffOnBlink As Integer
        Public TotalCycleTime As Integer
        Public OnTime As Integer
        Public OffTime As Integer
        Public MetaCycleOn As Integer
        Public MetaCycleOff As Integer
    End Structure

    <DllImport("Coredll")> _
    Private Shared Function NLedSetDevice(ByVal deviceId As Integer, ByRef info As NLED_SETTINGS_INFO) As Boolean
    End Function

    Private Shared Sub SetVibrate(ByVal state As Boolean)
        Dim info As New NLED_SETTINGS_INFO()
        info.LedNum = 1
        info.OffOnBlink = If(state, 1, 0)
        NLedSetDevice(1, info)
    End Sub



On most devices the vibration is set to LED device 1.
For more information on the API go here http://msdn.microsof...y/ms923732.aspx

As for turning off the backlight, that's easy as well.
Information on it can be found here http://msdn.microsof...y/aa455153.aspx



Thanks.. we did try implementing it.. but there was a error with "<DllImport("Coredll")>" we did try add reference.. but the coredll is not being found.. could u guide me of how to add refrence in vb step by step..

Thanks.. :)

This post has been edited by fizarah.parveen: 21 July 2009 - 01:14 AM

Was This Post Helpful? 0
  • +
  • -

#4 Mezius  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 72
  • Joined: 13-April 09

Re: Making a Phone Vibrate using VB.NET

Posted 22 July 2009 - 04:57 AM

The reference is system.core, it should be in the list of references you can choose on the .Net tab when adding a reference.

This post has been edited by Mezius: 22 July 2009 - 05:04 AM

Was This Post Helpful? 0
  • +
  • -

#5 fizarah.parveen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-July 09

Re: Making a Phone Vibrate using VB.NET

Posted 22 July 2009 - 08:33 PM

View PostMezius, on 22 Jul, 2009 - 03:57 AM, said:

The reference is system.core, it should be in the list of references you can choose on the .Net tab when adding a reference.


Hey thanks.. but I couldnt find that particular reference..

System
System.data
System.data.sqlClient
System.data.sqlserverce
System.Drawing
System.Messaging
System.Net.IrDA
System.web.Services
System.Windows.Forms
System.Windows.Forms.DataGrid
System.XML

This are those could be found.. is there any other reference could be used... i even tried searching the web for the system.core it gave for the windows.. (for computer)
Was This Post Helpful? 0
  • +
  • -

#6 Mezius  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 72
  • Joined: 13-April 09

Re: Making a Phone Vibrate using VB.NET

Posted 23 July 2009 - 06:25 AM

You are using windows mobile correct?

If so, make sure you have the SDK's installed correctly for 5/6 and make sure you have .net 2 and 3.5 sdk's installed.

First thing I do is install VS 2008 which includes the .net SDKs and the windows mobile SDKs, so I'm not sure which one you really need. It should be the windows mobile ones because it's the core of the OS.

Try manually adding the reference through browsing - the file on mine is in C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE

This post has been edited by Mezius: 23 July 2009 - 06:26 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1