Does anyone have some simple code with which I can open a website for people to view it? (And if you are really smart, can you tell me how to make the VB program to kick in if the user does not enter any input for 1 minute??)
Printable View
Does anyone have some simple code with which I can open a website for people to view it? (And if you are really smart, can you tell me how to make the VB program to kick in if the user does not enter any input for 1 minute??)
Hey,
You need to use the ShellExecute API....and need to pass the url as the parameter.
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim success As Integer
Function ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)
Dim api%
api% = ShellExecute(Frm.hwnd, "open", URL$, "", App.Path, WindowStyle%)
'Check return value
If api% < 31 Then
'error code - see api help for more info
MsgBox App.Title & " had a problem running your web browser." & _
"You should check that your browser is correctly installed." & _
"(Error" & Format$(api%) & ")", 48, "Browser Unavailable"
ShellToBrowser% = False
ElseIf api% = 32 Then
'no file association
MsgBox App.Title & " could not find a file association for " & _
URL$ & " on your system. You should check that your browser" & _
"is correctly installed and associated with this type of file.", 48, "Browser Unavailable"
ShellToBrowser% = False
Else
'It worked!
ShellToBrowser% = True
End If
End Function
Public Sub LaunchSite(Site As String, frm As Form)
success% = ShellToBrowser(frm, Site, 0)
End Sub
---
This code is from Compwiz and it worked for me well....And dont forget to pass on ur thanx to him :) :)
------------------
Regards,
Venkat
[email protected]
ICQ: 45714766
http://venkat.iscool.net
Thankyou :)
This will check to see if the user moved his mouse or pressed a key.
Add a timer, and set it's interval to 100.
Code:Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Sub Timer1_Timer()
Static lTimeCounter As Long
Dim lCounter As Long
Static xLastCursorPos As POINTAPI
Dim xCurrentCursorPos As POINTAPI
lTimeCounter = lTimeCounter + 1
'Check if a key has been pressed
For lCounter = 0 To 255
If GetAsyncKeyState(lCounter) <> 0 Then
'Key Has been pressed
lTimeCounter = 0
End If
Next
'Check if the mouse has moved
GetCursorPos xCurrentCursorPos
If (xCurrentCursorPos.x <> xLastCursorPos.x) Or (xCurrentCursorPos.y <> xLastCursorPos.y) Then
'Mouse has moved
lTimeCounter = 0
End If
xLastCursorPos = xCurrentCursorPos
If lTimeCounter = 600 Then
'Hee one minut has experied
MsgBox "Get back to work lazy boy"
End If
End Sub
Hope it helps,
------------------
Vincent van den Braken
EMail: [email protected]
ICQ: 15440110
Homepage: http://www.azzmodan.demon.nl