home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / intern2a / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-10-09  |  9.5 KB  |  292 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Internet Costs Controler"
  5.    ClientHeight    =   1155
  6.    ClientLeft      =   45
  7.    ClientTop       =   345
  8.    ClientWidth     =   4695
  9.    Icon            =   "Form1.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   1155
  13.    ScaleWidth      =   4695
  14.    StartUpPosition =   2  'CenterScreen
  15.    Begin VB.CommandButton cmdAbout 
  16.       Cancel          =   -1  'True
  17.       Caption         =   "&About"
  18.       Height          =   375
  19.       Left            =   3120
  20.       TabIndex        =   3
  21.       Top             =   720
  22.       Width           =   1335
  23.    End
  24.    Begin VB.Frame Options 
  25.       BorderStyle     =   0  'None
  26.       Enabled         =   0   'False
  27.       Height          =   1455
  28.       Left            =   840
  29.       TabIndex        =   4
  30.       Top             =   1260
  31.       Width           =   3015
  32.       Begin VB.CommandButton cmdReset 
  33.          Caption         =   "&Reset Options"
  34.          Height          =   375
  35.          Left            =   1560
  36.          TabIndex        =   13
  37.          Top             =   960
  38.          Width           =   1335
  39.       End
  40.       Begin VB.CommandButton cmdSave 
  41.          Caption         =   "&Save Options"
  42.          Height          =   375
  43.          Left            =   120
  44.          TabIndex        =   12
  45.          Top             =   960
  46.          Width           =   1335
  47.       End
  48.       Begin VB.TextBox Text1 
  49.          Alignment       =   1  'Right Justify
  50.          Height          =   285
  51.          Left            =   1200
  52.          TabIndex        =   11
  53.          Top             =   540
  54.          Width           =   1695
  55.       End
  56.       Begin VB.ComboBox Combo2 
  57.          Height          =   315
  58.          ItemData        =   "Form1.frx":0442
  59.          Left            =   2160
  60.          List            =   "Form1.frx":04FA
  61.          Style           =   2  'Dropdown List
  62.          TabIndex        =   8
  63.          Top             =   120
  64.          Width           =   615
  65.       End
  66.       Begin VB.ComboBox Combo1 
  67.          Height          =   315
  68.          ItemData        =   "Form1.frx":05E4
  69.          Left            =   1200
  70.          List            =   "Form1.frx":0606
  71.          Style           =   2  'Dropdown List
  72.          TabIndex        =   6
  73.          Top             =   120
  74.          Width           =   615
  75.       End
  76.       Begin VB.Label Label4 
  77.          AutoSize        =   -1  'True
  78.          Caption         =   "I&mpulse Cost:"
  79.          Height          =   195
  80.          Left            =   120
  81.          TabIndex        =   10
  82.          Top             =   540
  83.          Width           =   945
  84.       End
  85.       Begin VB.Label Label3 
  86.          AutoSize        =   -1  'True
  87.          Caption         =   "s"
  88.          Height          =   195
  89.          Left            =   2880
  90.          TabIndex        =   9
  91.          Top             =   180
  92.          Width           =   75
  93.       End
  94.       Begin VB.Label Label2 
  95.          AutoSize        =   -1  'True
  96.          Caption         =   "m"
  97.          Height          =   195
  98.          Left            =   1920
  99.          TabIndex        =   7
  100.          Top             =   180
  101.          Width           =   120
  102.       End
  103.       Begin VB.Label Label1 
  104.          AutoSize        =   -1  'True
  105.          Caption         =   "Impulse &Time:"
  106.          Height          =   195
  107.          Left            =   120
  108.          TabIndex        =   5
  109.          Top             =   180
  110.          Width           =   975
  111.       End
  112.    End
  113.    Begin VB.CommandButton cmdClose 
  114.       Caption         =   "&Close"
  115.       Height          =   375
  116.       Left            =   1680
  117.       TabIndex        =   2
  118.       Top             =   720
  119.       Width           =   1335
  120.    End
  121.    Begin VB.CommandButton cmdOptions 
  122.       Caption         =   "&Options >>"
  123.       Height          =   375
  124.       Left            =   240
  125.       TabIndex        =   1
  126.       Top             =   720
  127.       Width           =   1335
  128.    End
  129.    Begin VB.Timer Timer1 
  130.       Interval        =   1000
  131.       Left            =   4080
  132.       Top             =   120
  133.    End
  134.    Begin VB.Shape ProgressBar 
  135.       DrawMode        =   6  'Mask Pen Not
  136.       FillStyle       =   0  'Solid
  137.       Height          =   255
  138.       Left            =   120
  139.       Top             =   720
  140.       Width           =   2655
  141.    End
  142.    Begin VB.Shape Shape1 
  143.       Height          =   375
  144.       Left            =   1320
  145.       Top             =   720
  146.       Width           =   3255
  147.    End
  148.    Begin VB.Label Status 
  149.       Alignment       =   2  'Center
  150.       Caption         =   "You are currently Offline."
  151.       Height          =   255
  152.       Left            =   120
  153.       TabIndex        =   14
  154.       Top             =   360
  155.       Width           =   4455
  156.    End
  157.    Begin VB.Line Line1 
  158.       BorderColor     =   &H80000014&
  159.       BorderWidth     =   2
  160.       X1              =   120
  161.       X2              =   4560
  162.       Y1              =   1200
  163.       Y2              =   1200
  164.    End
  165.    Begin VB.Label Timed 
  166.       Alignment       =   2  'Center
  167.       Caption         =   "You are currently Offline."
  168.       Height          =   255
  169.       Left            =   120
  170.       TabIndex        =   0
  171.       Top             =   120
  172.       Width           =   4455
  173.    End
  174. Attribute VB_Name = "Form1"
  175. Attribute VB_GlobalNameSpace = False
  176. Attribute VB_Creatable = False
  177. Attribute VB_PredeclaredId = True
  178. Attribute VB_Exposed = False
  179. 'General variable declaration
  180. 'ITime = impulse time
  181. 'ICost = impulse cost
  182. 'NetStart = time when you connected
  183. 'NetCount = total connection impulses
  184. 'NetCost = total connection cost
  185. Private ITime As Integer, ICost As Single
  186. Private NetStart As Long, NetCount As Integer, NetCost As Long
  187. Private OnLine As Boolean
  188. Private Sub cmdAbout_Click()
  189. 'Generate a standard About Message Box
  190.     MsgBox "Programmed by Pedro Lamas" & vbCrLf & "Copyright 
  191. 1997-1999 Underground Software" & vbCrLf & vbCrLf & "Home-Page (Dedicated to VB): www.terravista.pt/portosanto/3723/" & vbCrLf & "E-Mail: sniper@hotpop.com", vbApplicationModal + vbInformation, "Credits!"
  192. End Sub
  193. Private Sub cmdClose_Click()
  194. 'End the program
  195.     End
  196. End Sub
  197. Private Sub cmdOptions_Click()
  198.     If cmdOptions.Caption = "&Options >>" Then
  199. 'Show the Options Panel
  200.         ResetOptions
  201.         cmdOptions.Caption = "&Options <<"
  202.         Me.Height = 3045
  203.         Options.Enabled = True
  204. 'Disable the timer
  205.         Timer1.Enabled = False
  206.     Else
  207. 'Hide the Options Panel
  208.         cmdOptions.Caption = "&Options >>"
  209.         Me.Height = 1545
  210.         Options.Enabled = False
  211. 'Enable the timer
  212.         Timer1.Enabled = True
  213.     End If
  214. End Sub
  215. Private Sub cmdReset_Click()
  216. 'Reset the options, by reloading the settings
  217.     ResetOptions
  218. End Sub
  219. Private Sub cmdSave_Click()
  220. 'Update the options variables
  221.     ITime = Combo1 * 60 + Combo2
  222.     ICost = CSng(Text1)
  223. 'Save the options on the Windows Registry
  224.     SaveSetting "Internet Costs Control", "ops", "ITime", ITime
  225.     SaveSetting "Internet Costs Control", "ops", "ICost", ICost
  226. End Sub
  227. Private Sub Form_Load()
  228. 'Set the options, by loading the setings
  229.     ResetOptions
  230. 'Align the Impulse Progress Bar
  231.     Shape1.Move Timed.Left, Timed.Top, Timed.Width, Timed.Height + Status.Height
  232.     ProgressBar.Move Timed.Left + 30, Timed.Top + 30, 0, Timed.Height + Status.Height - 60
  233.     ProgressBar.Tag = Timed.Width - 60
  234. End Sub
  235. Private Sub Timer1_Timer()
  236.     On Error Resume Next
  237.     Dim Ret As Long, PassedTime As Long
  238. 'Check if you are connected
  239.     If IsRASConnected Then
  240. 'Get the time you have been connected
  241.         PassedTime = Timer - NetStart
  242.         If OnLine Then
  243. 'If you were already connected,
  244.             Timed = "OnLine for " & TimeSerial(0, 0, PassedTime)
  245.             If Int(PassedTime / ITime + 1) > NetCount Then
  246. 'Update the Costs Panel
  247.                 NetCount = Int(PassedTime / ITime + 1)
  248.                 NetCost = NetCount * ICost
  249.                 Status = "You've already spent " & Format(NetCost, "Currency")
  250.                 ProgressBar.Width = Int(ProgressBar.Tag)
  251.             Else
  252. 'Update the Impulse Progress Bar
  253.                 ProgressBar.Width = Int(ProgressBar.Tag) / ITime * (PassedTime Mod ITime)
  254.             End If
  255.         Else
  256. 'If you weren't connected, set the session variables
  257.             NetStart = Timer
  258.             NetCount = 1
  259.             NetCost = ICost
  260.             Timed = "OnLine for " & TimeSerial(0, 0, 0)
  261.             Status = "You've already spent " & Format(NetCost, "Currency")
  262. 'Change the Online flag to True
  263.             OnLine = True
  264. 'Disable the Options CommandButton
  265.             cmdOptions.Enabled = False
  266.         End If
  267.     Else
  268. 'If you were connected,
  269.         If OnLine Then
  270. 'Update the Costs Panel
  271.             Timed = "OffLine. You've been Online for " & TimeSerial(0, 0, Timer - NetStart)
  272.             Status = "You've spent " & Format(NetCost, "Currency")
  273.             ProgressBar.Width = 0
  274. 'Change the Online flag to False
  275.             OnLine = False
  276. 'Enable the Options CommandButton
  277.             cmdOptions.Enabled = True
  278.         End If
  279.     End If
  280. 'Do all events
  281.     DoEvents
  282. End Sub
  283. Private Sub ResetOptions()
  284. 'Get the program settings from Windows Registry
  285.     ITime = Int(GetSetting("Internet Costs Control", "Ops", "ITime", 180))
  286.     ICost = CSng(GetSetting("Internet Costs Control", "Ops", "ICost", 10))
  287. 'Update the Options Controls with the setting values
  288.     Combo1 = Int(ITime / 60)
  289.     Combo2 = ITime - 60 * Int(ITime / 60)
  290.     Text1 = ICost
  291. End Sub
  292.