Advertisement

09.27.2008 at 05:49PM PDT, ID: 23769046
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Program Not Working Properly on Computers Without Visual Studio

Asked by Gunit2507 in Visual Basic Programming, Microsoft Visual Basic.Net, Microsoft Visual Studio Express

I designed a program, included below, that tracks the amount of time my user is online and then disables internet browsing after their time has expired.  It works great on my computer in debug mode through Visual Studio 2005 or by just running the program locally.  When I installed it on several other computers it no longer worked properly (doesn't cancel the new window or navigation events). So I thought it was my programing, so I instally Visual Studio 2005 on the computer having problems so I could run the program in debug mode and determine why the program only works on my computer.  When I ran the program in debug mode on the "problem" computer it worked perfectly, and it event worked great when I ran the program locally.  I then uninstalled Visual Studio 2005, ran the program locally again and it didn't work properly again.  So why does Visual Studio 2005 need to be installed for my program to work properly?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
Public Class FormPrimary
 
    Private MySettingLocation As New OleDb.OleDbConnection(My.Settings.MyConnectionString)
    Private WithEvents MyExplorerWindows As New SHDocVw.ShellWindows
    Private WithEvents MyBrowserExplorer As SHDocVw.ShellBrowserWindow
    Private MyValidWebsites() As String = Split(My.Settings.MyAllowedWebsites, "|")
    Private MyLoginUsername() As String = Split(My.User.Name, "\")
 
    Declare Function IsIconic Lib "user32" (ByVal HWND As Integer) As Integer
    Declare Function GetForegroundWindow Lib "user32" () As Integer
    Declare Function GetWindowTextA Lib "user32" (ByVal HWND As Integer, ByVal Title As StringBuilder, ByVal CCH As Integer) As Integer
 
    Private Function ValidateDomainName(ByVal MyLocationURL As String) As Boolean
 
        For MyInteger As Integer = LBound(MyValidWebsites) To UBound(MyValidWebsites)
            If MyLocationURL.Contains(MyValidWebsites(MyInteger)) = True Then
                ValidateDomainName = True : Exit For
            End If
        Next
 
    End Function
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerSystem.Tick
        On Error Resume Next
        Dim MyCheck As Boolean = False
 
        If My.Computer.Clock.LocalTime.Date = My.Settings.MyInternetUserDate.Date.AddDays(1) Then
            Me.CreateRecord(Now.Date)
            Me.IconTray.Icon = My.Resources.Connected
        End If
 
        If Not MyExplorerWindows.Count > 0 Then
            Me.TimerInternet.Enabled = False
        End If
 
        For Each MyCurrentExplorer As SHDocVw.ShellBrowserWindow In MyExplorerWindows
            If Path.GetFileNameWithoutExtension(MyCurrentExplorer.FullName).ToLower = "iexplore" Then
 
                If IsIconic(MyCurrentExplorer.HWND) = 0 Then
                    If Not Me.ValidateDomainName(MyCurrentExplorer.LocationURL) Then
                        MyCheck = True : Exit For
                    End If
                End If
 
 
            End If
        Next
 
        Me.TimerInternet.Enabled = MyCheck
        Me.IconTray.Text = IIf(My.Settings.MyInternetTimeLeft >= 0, My.Settings.MyInternetTimeLeft, 0) & " Minutes Remaining (" & IIf(Me.TimerInternet.Enabled = True, "", "Not ") & "Tracking)"
 
        For Each MyCurrentExplorer As SHDocVw.ShellBrowserWindow In MyExplorerWindows
            If Path.GetFileNameWithoutExtension(MyCurrentExplorer.FullName).ToLower = "iexplore" Then
 
                If GetForegroundWindow = MyCurrentExplorer.HWND Then
 
                    Dim MyFocusedString As New System.Text.StringBuilder(256)
                    Dim MyFocusedHeader As Integer = GetWindowTextA(GetForegroundWindow(), MyFocusedString, 256)
                    'If Not MyCurrentExplorer.Busy = True Then
 
                    If MyCurrentExplorer.Document.ToString = "mshtml.HTMLDocumentClass" Then
                        If Replace(MyFocusedString.ToString, " - Windows Internet Explorer", "") = MyCurrentExplorer.Document.Title Then
                            MyBrowserExplorer = MyCurrentExplorer
                            Exit For
                        End If
                    Else
                        If Replace(MyFocusedString.ToString, " - Windows Internet Explorer", "") = MyCurrentExplorer.LocationURL Then
                            MyBrowserExplorer = MyCurrentExplorer
                            Exit For
                        Else
                            Debug.WriteLine("Problem")
                        End If
                    End If
                    'End If
 
                End If
 
            End If
        Next
 
    End Sub
 
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerInternet.Tick
 
        My.Settings.MyInternetTimeLeft = My.Settings.MyInternetTimeLeft - 1
 
        UpdateRecord(Now.Date)
 
        If My.Settings.MyInternetTimeLeft = 5 Then
            Me.IconTray.BalloonTipText = "You have 5 minutes of non-restricted internet use remaining."
            Me.IconTray.ShowBalloonTip(5000)
        End If
 
        If My.Settings.MyInternetTimeLeft = 0 Then
            Me.IconTray.BalloonTipText = "You have 0 minutes of non-restricted internet use remaining."
            Me.IconTray.ShowBalloonTip(5000)
            Me.IconTray.Icon = My.Resources.Disabled
        End If
 
    End Sub
    Private Sub MyBrowserExplorer_BeforeNavigate2(ByVal pDisp As Object, ByRef URL As Object, ByRef Flags As Object, ByRef TargetFrameName As Object, ByRef PostData As Object, ByRef Headers As Object, ByRef Cancel As Boolean) Handles MyBrowserExplorer.BeforeNavigate2
 
        If Me.ValidateDomainName(URL) = False And My.Settings.MyInternetTimeLeft <= 0 Then
            Cancel = True
        End If
 
    End Sub
    Private Sub MyBrowserExplorer_NewWindow3(ByRef ppDisp As Object, ByRef Cancel As Boolean, ByVal dwFlags As UInteger, ByVal bstrUrlContext As String, ByVal bstrUrl As String) Handles MyBrowserExplorer.NewWindow3
 
        If Me.ValidateDomainName(bstrUrl) = False And My.Settings.MyInternetTimeLeft <= 0 Then
            MyBrowserExplorer.RegisterAsBrowser = True
            MyBrowserExplorer.Visible = True
            ppDisp = MyBrowserExplorer
            Cancel = True
 
        End If
    End Sub
 
    Private Sub FormPrimary_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.SelectRecord(Now.Date) : Me.TimerSystem.Start()
    End Sub
 
    Private Sub SelectRecord(ByVal MyRecordDate As Date)
 
        Me.MySettingLocation.Open()
 
        Dim MyQuery As String = "SELECT * FROM AccessEvents "
        MyQuery = MyQuery & "WHERE InternetDate =#" & MyRecordDate & "# "
        MyQuery = MyQuery & "AND LoginName ='" & MyLoginUsername(1) & "'"
 
        Dim MyDataCommand As New OleDb.OleDbCommand(MyQuery, MySettingLocation)
        Dim MyDataRecords As OleDb.OleDbDataReader = MyDataCommand.ExecuteReader()
 
        If MyDataRecords.HasRows = True Then
            While MyDataRecords.Read()
                My.Settings.MyInternetTimeLeft = MyDataRecords("TimeRemaining")
                My.Settings.MyInternetUserDate = MyDataRecords("InternetDate")
            End While
            Me.MySettingLocation.Close()
            Me.IconTray.Icon = IIf(My.Settings.MyInternetTimeLeft <= 0, My.Resources.Disabled, My.Resources.Connected)
            Me.IconTray.Text = IIf(My.Settings.MyInternetTimeLeft >= 0, My.Settings.MyInternetTimeLeft, 0) & " Minutes Remaining (" & IIf(Me.TimerInternet.Enabled = True, "", "Not ") & "Tracking)"
        Else
            Me.MySettingLocation.Close() : Me.CreateRecord(MyRecordDate)
        End If
 
    End Sub
    Private Sub CreateRecord(ByVal MyRecordDate As Date)
 
        Me.MySettingLocation.Open()
 
        Dim MyQuery As String = "INSERT INTO AccessEvents (LoginName, InternetDate) "
        MyQuery = MyQuery & "VALUES ('" & MyLoginUsername(1) & "', #" & MyRecordDate & "#)"
 
        Dim MyDataCommand As New OleDb.OleDbCommand(MyQuery, MySettingLocation)
        MyDataCommand.ExecuteReader() : Me.MySettingLocation.Close() : Me.SelectRecord(Now.Date)
 
    End Sub
    Private Sub UpdateRecord(ByVal MyRecordDate As Date)
 
        Me.MySettingLocation.Open()
 
        Dim MyQuery As String = "UPDATE AccessEvents "
        MyQuery = MyQuery & "SET TimeRemaining =" & My.Settings.MyInternetTimeLeft & " "
        MyQuery = MyQuery & "WHERE LoginName='" & MyLoginUsername(1) & "' "
        MyQuery = MyQuery & "AND InternetDate=#" & MyRecordDate & "#"
 
        Dim MyDataCommand As New OleDb.OleDbCommand(MyQuery, MySettingLocation)
        MyDataCommand.ExecuteReader() : Me.MySettingLocation.Close()
 
    End Sub
 
End Class
[+][-]09.27.2008 at 06:46PM PDT, ID: 22589423

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.28.2008 at 12:45AM PDT, ID: 22590190

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 06:23AM PDT, ID: 22596070

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic Programming, Microsoft Visual Basic.Net, Microsoft Visual Studio Express
Sign Up Now!
Solution Provided By: DanielWilson
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.29.2008 at 11:08AM PDT, ID: 22598947

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 12:17PM PDT, ID: 22599624

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 03:09PM PDT, ID: 22601279

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.29.2008 at 06:08PM PDT, ID: 22602048

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 - Hierarchy / EE_QW_2_20070628