-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmMain.frm
871 lines (745 loc) · 26.2 KB
/
frmMain.frm
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "msinet.ocx"
Begin VB.Form frmMain
BorderStyle = 0 'None
Caption = "PSC - Ticker"
ClientHeight = 3915
ClientLeft = 0
ClientTop = 0
ClientWidth = 7470
BeginProperty Font
Name = "Tahoma"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
ScaleHeight = 3915
ScaleWidth = 7470
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.Timer TimerOneSec
Interval = 1000
Left = 6990
Top = 1785
End
Begin VB.PictureBox picBack
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 3915
Left = 0
ScaleHeight = 3885
ScaleWidth = 7440
TabIndex = 1
Top = 0
Width = 7470
Begin VB.CommandButton cmdOptions
Caption = "Options"
Height = 345
Left = 6045
TabIndex = 8
Top = 285
Width = 1365
End
Begin VB.ComboBox cboWorlds
Height = 360
Left = 30
Style = 2 'Dropdown List
TabIndex = 7
Top = 285
Width = 6015
End
Begin InetCtlsObjects.Inet Inet1
Left = 6420
Top = 1590
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
End
Begin VB.PictureBox picCodeHolder
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 3210
Left = 30
ScaleHeight = 3180
ScaleWidth = 7350
TabIndex = 3
Top = 660
Width = 7380
Begin MSComctlLib.ListView lsvwNew
Height = 3225
Left = -15
TabIndex = 6
Top = -30
Width = 7380
_ExtentX = 13018
_ExtentY = 5689
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
_Version = 393217
ForeColor = 0
BackColor = -2147483643
BorderStyle = 1
Appearance = 0
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
NumItems = 6
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "Num"
Object.Width = 0
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "ID"
Object.Width = 0
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "World"
Object.Width = 2646
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "Title"
Object.Width = 5292
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "Author"
Object.Width = 3528
EndProperty
BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 5
Text = "Time"
Object.Width = 1235
EndProperty
End
End
Begin VB.Line Line1
BorderColor = &H8000000C&
BorderWidth = 2
X1 = 6900
X2 = 7050
Y1 = 180
Y2 = 180
End
Begin VB.Label lblMini
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
ForeColor = &H80000008&
Height = 270
Left = 6810
TabIndex = 5
Top = -15
Width = 330
End
Begin VB.Label lblClose
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
Caption = "X"
ForeColor = &H80000008&
Height = 270
Left = 7125
TabIndex = 4
Top = -15
Width = 330
End
Begin VB.Label lblTitle
Alignment = 2 'Center
Appearance = 0 'Flat
AutoSize = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "Planet Source Code - Code Ticker"
ForeColor = &H80000008&
Height = 270
Left = -15
TabIndex = 2
Top = -15
Width = 7470
End
End
Begin VB.Label lblStandBy
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BorderStyle = 1 'Fixed Single
Caption = "PSC Ticker: 0 Code Samples "
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 240
Left = 3690
TabIndex = 0
Top = 1665
Width = 2460
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public bLoading As Boolean
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOPMOST = -1
Private iTimerMinimize As Integer
Public iRefreshSelWorldTimer As Integer
Public iRefreshSelWorld As Integer
Private bShowForm As Boolean
Private Sub cboWorlds_Change()
iTimerMinimize = 0
If bLoading = False Then ChangeWorldViews
End Sub
Private Sub cboWorlds_Click()
iTimerMinimize = 0
If bLoading = False Then ChangeWorldViews
End Sub
Private Sub cmdOptions_Click()
'LOADS OPTIONS FROM BUTTON AND THEN UPDATES LIST
frmOptions.Show 1
cboWorlds.ListIndex = 0
ChangeWorldViews
End Sub
Private Sub Form_Load()
bLoading = True
'LOAD OPTIONS DIALOG
LoadOptions
'LOAD FORM IN STANDBY POSITION
lblStandBy.Visible = True
picBack.Visible = False
Me.Height = 240
Me.Width = 2460
Me.Move Screen.Width - Me.Width - 1200, 75
lblStandBy.Left = 0
lblStandBy.Top = 0
'SET ON TOP OF EVERYTHING
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
'DOWNLOAD THE PSC FILES
ScanHTTPFiles True
bLoading = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
iTimerMinimize = 0
End Sub
Private Sub lblClose_Click()
End
End Sub
Private Sub lblMini_Click()
'SENDS FOR TO STANDBY
lblStandBy.Visible = True
picBack.Visible = False
Me.Height = 240
Me.Width = 2460
Me.Move Screen.Width - Me.Width - 1200, 75
'TimerOneSec.Enabled = False
lblStandBy.Left = 0
lblStandBy.Top = 0
bShowForm = False
End Sub
Private Sub lblOlderTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
iTimerMinimize = 0
End Sub
Private Sub lblStandBy_Click()
'SENDS FORM TO VIEW MODE
lblStandBy.Visible = False
picBack.Visible = True
Me.Height = 3915
Me.Width = 7470
Me.Move Screen.Width - Me.Width - 1200, 75
iTimerMinimize = 0
bShowForm = True
End Sub
Private Sub lblTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
iTimerMinimize = 0
End Sub
Private Sub lsvwNew_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
iTimerMinimize = 0
End Sub
Private Sub lsvwNew_DblClick()
'OPENS NEW IE WINDOW WITH CODE LINK
lblMini_Click
Dim iSel As Integer
iSel = lsvwNew.SelectedItem
Shell "C:\Program Files\Internet Explorer\iexplore.exe " & "http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=" & lsvwNew.ListItems(iSel).ListSubItems(1).Text & "&lngWId=" & GetWorldText2ID(lsvwNew.ListItems(iSel).ListSubItems(2).Text), vbNormalFocus
End Sub
Private Sub lsvwNew_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
iTimerMinimize = 0
End Sub
Private Sub lsvwOlder_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
iTimerMinimize = 0
End Sub
Private Sub picBack_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
iTimerMinimize = 0
End Sub
Private Sub picCodeHolder_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
iTimerMinimize = 0
End Sub
Private Sub TimerOneSec_Timer()
'ACTIVATED EVERY SECOND AND CHECKS FOR UNACTIVE MOUSE TO MAKE FORM STANDBY
'ALSO COUNTS UP FOR REFRESHING WORLD SELECTED IN COMBO BOX
If iTimerMinimize = 5 And bShowForm = True Then
lblStandBy.Visible = True
picBack.Visible = False
Me.Height = 240
Me.Width = 2460
Me.Move Screen.Width - Me.Width - 1200, 75
lblStandBy.Left = 0
lblStandBy.Top = 0
bShowForm = False
Else
iTimerMinimize = iTimerMinimize + 1
bShowForm = True
End If
lblStandBy.Caption = "PSC Ticker: " & lsvwNew.ListItems.Count & " code samples"
If iRefreshSelWorldTimer >= iRefreshSelWorld And lblStandBy.Visible = True And bLoading = False Then
'CHANGES/REFRESHES THE CURRENT WORLD SELECTED IN COMBO BOX
ChangeWorldViews
iRefreshSelWorldTimer = 0
Else
iRefreshSelWorldTimer = iRefreshSelWorldTimer + 1
End If
End Sub
Public Sub LoadOptions()
'LOAD OPTIONS DIALOG
'I THOUGHT I WAS GOING TO DO MORE IN THIS FUNCTION :)
frmOptions.Show 1
End Sub
Public Sub ScanHTTPFiles(bFirstScan As Boolean)
'THIS FUNCTION SPLITS THE STRING GENERATED THROUGH THE OPTIONS DIALOG
'THEN SCANS EACH WORLD ONE BY ONE
Dim aResult() As String, i As Long
aResult = Split(sCodeWorldURLS, "|")
If bFirstScan = True Then
frmWait.Visible = True
End If
For i = LBound(aResult) To UBound(aResult)
ScanFile FormatNumber(aResult(i), 0)
Next
Unload frmWait
End Sub
Function ScanFile(lngWID As Integer)
'THIS FUNCTION DOWNLOADS THE ACTUAL TICKER PAGE AND SAVES TO HD
'AFTER SUCCESS OF DOWNLOAD IT THEN PARSES THE FILE FOR CODE SAMPLES
If Dir(App.Path & "\CODEPAGES\", vbDirectory) = "" Then
MkDir (App.Path & "\CODEPAGES\")
End If
frmWait.lblStatusTitle.Caption = "Downloading World..."
frmWait.lblWorldID.Caption = GetWorldIDText(lngWID)
DoEvents
If DownloadFile("http://www.planet-source-code.com/vb/linktous/ScrollingCode.asp?lngWId=" & lngWID & "&blnHideChannelSubscribe=true&blnLaunchLinkInNewWindow=true&blnShowTickerWorldTitle=false", App.Path & "\CODEPAGES\PSC-ID" & lngWID & ".asp") = True Then
ParseFile App.Path & "\CODEPAGES\PSC-ID" & lngWID & ".asp", GetWorldIDText(lngWID)
Else
MsgBox "There was a problem downloading one of the code files!"
End
End If
lblStandBy.Caption = "PSC Ticker: " & lsvwNew.ListItems.Count & " code samples"
End Function
Public Function DownloadFile(strURL As String, _
strDestination As String, _
Optional UserName As String = Empty, _
Optional Password As String = Empty) _
As Boolean
'THIS FUNCTION WAS TAKEN FROM THE PSC CODE FOUND HERE:
'http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=7335&lngWId=1
'THANKS FOR THE GOOD CODE
'I HAD TO COMMENT OUT THE MOVIE AND LABEL UPDATES JUST TO DO THE DOWNLOAD
' Funtion DownloadFile: Download a file via HTTP
'
' Author: Jeff Cockayne
'
' Inputs: strURL String; the source URL of the file
' strDestination; valid Win95/NT path to where you want it
' (i.e. "C:\Program Files\My Stuff\Purina.pdf")
'
' Returns: Boolean; Was the download successful?
Const CHUNK_SIZE As Long = 1024 ' Download chunk size
Const ROLLBACK As Long = 4096 ' Bytes to roll back on resume
' You can be less conservative,
' and roll back less, but I
' don't recommend it.
Dim bData() As Byte ' Data var
Dim blnResume As Boolean ' True if resuming download
Dim intFile As Integer ' FreeFile var
Dim lngBytesReceived As Long ' Bytes received so far
Dim lngFileLength As Long ' Total length of file in bytes
Dim lngX ' Temp long var
Dim sglLastTime As Single ' Time last chunk received
Dim sglRate As Single ' Var to hold transfer rate
Dim sglTime As Single ' Var to hold time remaining
Dim strFile As String ' Temp filename var
Dim strHeader As String ' HTTP header store
Dim strHost As String ' HTTP Host
On Local Error GoTo InternetErrorHandler
' Start with Cancel flag = False
CancelSearch = False
' Get just filename (without dirs) for display
strFile = ReturnFileOrFolder(strDestination, True)
strHost = ReturnFileOrFolder(strURL, True, True)
SourceLabel = Empty
TimeLabel = Empty
ToLabel = Empty
RateLabel = Empty
' Pre-open the AVI
'With Animation1
' .AutoPlay = True
' .Open App.Path & "\DOWNLD2.AVI"
'End With
' Show the download status form
'Show
' Move form into view
'Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
StartDownload:
If blnResume Then
StatusLabel = "Resuming download..."
lngBytesReceived = lngBytesReceived - ROLLBACK
If lngBytesReceived < 0 Then lngBytesReceived = 0
Else
StatusLabel = "Getting file information..."
End If
' Give the system time to update the form gracefully
DoEvents
' Download file
With Inet1
.URL = strURL
.UserName = UserName
.Password = Password
' GET file, sending the magic resume input header...
.Execute , "GET", , "Range: bytes=" & CStr(lngBytesReceived) & "-" & vbCrLf
' While initiating connection, yield CPU to Windows
While .StillExecuting
DoEvents
' If user pressed Cancel button on StatusForm
' then fail, cancel, and exit this download
If CancelSearch Then GoTo ExitDownload
Wend
'StatusLabel = "Saving:"
'SourceLabel = FitText(SourceLabel, strHost & " from " & .RemoteHost)
'ToLabel = FitText(ToLabel, strDestination)
' Get first header ("HTTP/X.X XXX ...")
strHeader = .GetHeader
End With
' Trap common HTTP response codes
Select Case Mid(strHeader, 10, 3)
Case "200" ' OK
' If resuming, however, this is a failure
If blnResume Then
' Delete partially downloaded file
Kill strDestination
' Prompt
If MsgBox("The server is unable to resume this download." & _
vbCr & vbCr & _
"Do you want to continue anyway?", _
vbExclamation + vbYesNo, _
"Unable to Resume Download") = vbYes Then
' Yes - continue anyway:
' Set resume flag to False
blnResume = False
Else
' No - cancel
CancelSearch = True
GoTo ExitDownload
End If
End If
Case "206" ' 206=Partial Content, which is GREAT when resuming!
Case "204" ' No content
MsgBox "Nothing to download!", _
vbInformation, _
"No Content"
CancelSearch = True
GoTo ExitDownload
Case "401" ' Not authorized
MsgBox "Authorization failed!", _
vbCritical, _
"Unauthorized"
CancelSearch = True
GoTo ExitDownload
Case "404" ' File Not Found
MsgBox "The file, " & _
"""" & Inet1.URL & """" & _
" was not found!", _
vbCritical, _
"File Not Found"
CancelSearch = True
GoTo ExitDownload
Case vbCrLf ' Empty header
MsgBox "Cannot establish connection." & vbCr & vbCr & _
"Check your Internet connection and try again.", _
vbExclamation, _
"Cannot Establish Connection"
CancelSearch = True
GoTo ExitDownload
Case Else
' Miscellaneous unexpected errors
strHeader = Left(strHeader, InStr(strHeader, vbCr))
If strHeader = Empty Then strHeader = "<nothing>"
MsgBox "The server returned the following response:" & _
vbCr & vbCr & _
strHeader, _
vbCritical, _
"Error Downloading File"
CancelSearch = True
GoTo ExitDownload
End Select
' Get file length with "Content-Length" header request
If blnResume = False Then
' Set timer for gauging download speed
sglLastTime = Timer - 1
strHeader = Inet1.GetHeader("Content-Length")
lngFileLength = Val(strHeader)
If lngFileLength = 0 Then
GoTo ExitDownload
End If
End If
' Check for available disk space first...
' If on a physical or mapped drive. Can't with a UNC path.
If Mid(strDestination, 2, 2) = ":\" Then
If DiskFreeSpace(Left(strDestination, _
InStr(strDestination, "\"))) < lngFileLength Then
' Not enough free space to download file
MsgBox "There is not enough free space on disk for this file." _
& vbCr & vbCr & "Please free up some disk space and try again.", _
vbCritical, _
"Insufficient Disk Space"
GoTo ExitDownload
End If
End If
' Prepare display
'
' Progress Bar
'With ProgressBar
' .Value = 0
' .Max = lngFileLength
'End With
' Give system a chance to show AVI
DoEvents
' Reset bytes received counter if not resuming
If blnResume = False Then lngBytesReceived = 0
On Local Error GoTo FileErrorHandler
' Create destination directory, if necessary
strHeader = ReturnFileOrFolder(strDestination, False)
If Dir(strHeader, vbDirectory) = Empty Then
MkDir strHeader
End If
' If no errors occurred, then spank the file to disk
intFile = FreeFile() ' Set intFile to an unused file.
' Open a file to write to.
Open strDestination For Binary Access Write As #intFile
' If resuming, then seek byte position in downloaded file
' where we last left off...
If blnResume Then Seek #intFile, lngBytesReceived + 1
Do
' Get chunks...
bData = Inet1.GetChunk(CHUNK_SIZE, icByteArray)
Put #intFile, , bData ' Put it into our destination file
If CancelSearch Then Exit Do
lngBytesReceived = lngBytesReceived + UBound(bData, 1) + 1
sglRate = lngBytesReceived / (Timer - sglLastTime)
sglTime = (lngFileLength - lngBytesReceived) / sglRate
TimeLabel = FormatTime(sglTime) & _
" (" & _
FormatFileSize(lngBytesReceived) & _
" of " & _
FormatFileSize(lngFileLength) & _
" copied)"
RateLabel = FormatFileSize(sglRate, "###.0") & "/Sec"
'ProgressBar.Value = lngBytesReceived
'Me.Caption = Format((lngBytesReceived / lngFileLength), "##0%") & _
' " of " & strFile & " Completed"
Loop While UBound(bData, 1) > 0 ' Loop while there's still data...
Close #intFile
ExitDownload:
' Success if the # of bytes transferred = content length
If lngBytesReceived = lngFileLength Then
StatusLabel = "Download completed!"
DownloadFile = True
Else
If Dir(strDestination) = Empty Then
CancelSearch = True
Else
' Resume? (If not cancelled)
If CancelSearch = False Then
If MsgBox("The connection with the server was reset." & _
vbCr & vbCr & _
"Click ""Retry"" to resume downloading the file." & _
vbCr & "(Approximate time remaining: " & FormatTime(sglTime) & ")" & _
vbCr & vbCr & _
"Click ""Cancel"" to cancel downloading the file.", _
vbExclamation + vbRetryCancel, _
"Download Incomplete") = vbRetry Then
' Yes
blnResume = True
GoTo StartDownload
End If
End If
End If
' No or unresumable failure:
' Delete partially downloaded file
If Not Dir(strDestination) = Empty Then Kill strDestination
DownloadFile = False
End If
CleanUp:
' Close AVI
'Animation1.Close
' Make sure that the Internet connection is closed...
Inet1.Cancel
' ...and exit this function
'Unload Me
Exit Function
InternetErrorHandler:
' Err# 9 occurs when UBound(bData,1) < 0
If Err.Number = 9 Then Resume Next
' Other errors...
MsgBox "Error: " & Err.Description & " occurred.", _
vbCritical, _
"Error Downloading File"
Err.Clear
GoTo ExitDownload
FileErrorHandler:
MsgBox "Cannot write file to disk." & _
vbCr & vbCr & _
"Error " & Err.Number & ": " & Err.Description, _
vbCritical, _
"Error Downloading File"
CancelSearch = True
Err.Clear
GoTo ExitDownload
End Function
Public Sub ParseFile(sFile As String, sWorld As String)
'THIS IS PART I WANTED TO DO THE MOST. PARSE THE ASP FILE AFTER DOWNLOADING
'AFTER PARSING THE FILE IT THEN INSERTS THE INFO INTO THE LIST VIEW FOR VIEWING
'IF THE HTML CODE CHANGES IN THE ASP FILE THIS WILL MOST LIKELY NEED TO BE MODIFIED
Dim sFileText As String
Dim i As Integer
Dim i2 As Integer
Dim sCodeID As String
Dim sCodeTitle As String
Dim sCodeBy As String
sFileText = FileText(sFile)
'MsgBox sFileText
For i = 1 To Len(sFileText)
If Mid(sFileText, i, 10) = "txtCodeId=" Then
i = i + 10
i2 = i
sCodeID = ""
For i2 = i To i + 20
If IsNumeric(Mid(sFileText, i2, 1)) = True Then
sCodeID = sCodeID & Mid(sFileText, i2, 1)
Else
Exit For
End If
Next
i = i2
For i2 = i To i + 30
If Mid(sFileText, i2, 1) = ">" Then
Exit For
End If
Next
i = i2 + 1
sCodeTitle = ""
For i2 = i To i + 100 'GIVE ENOUGH SPACES FOR LONG TITLES
If Mid(sFileText, i2, 1) <> "<" Then
sCodeTitle = sCodeTitle & Mid(sFileText, i2, 1)
Else
Exit For
End If
Next
i = i2
For i2 = i To i + 50
If Mid(sFileText, i2, 2) = "By" Then
Exit For
End If
Next
i = i2 + 3
sCodeBy = ""
For i2 = i To i + 50
If Mid(sFileText, i2, 6) <> " " Then
sCodeBy = sCodeBy & Mid(sFileText, i2, 1)
Else
Exit For
End If
Next
i = i2 + 14
sCodeDate = ""
For i2 = i To i + 5
If Mid(sFileText, i2, 1) <> "<" Then
sCodeDate = sCodeDate & Mid(sFileText, i2, 1)
Else
Exit For
End If
Next
lsvwNew.ListItems.Add , , lsvwNew.ListItems.Count + 1
lsvwNew.ListItems(lsvwNew.ListItems.Count).ListSubItems.Add 1, , sCodeID
lsvwNew.ListItems(lsvwNew.ListItems.Count).ListSubItems.Add 2, , sWorld
lsvwNew.ListItems(lsvwNew.ListItems.Count).ListSubItems.Add 3, , sCodeTitle
lsvwNew.ListItems(lsvwNew.ListItems.Count).ListSubItems.Add 4, , sCodeBy
lsvwNew.ListItems(lsvwNew.ListItems.Count).ListSubItems.Add 5, , sCodeDate
lsvwNew.Refresh
End If
Next
End Sub
Function FileText(ByVal filename As String) As String
'READS A FILE TO THE END
Dim handle As Integer
handle = FreeFile
Open filename$ For Binary As #handle
FileText = Space$(LOF(handle))
Get #handle, , FileText
Close #handle
End Function
Public Sub ChangeWorldViews()
'IF THE COMBO BOX IS CLICKED OR CHANGED THIS IS FIRED
'ALSO THIS IS FIRED FOR AUTO REFRESHES
If lblStandBy.Visible = False Then frmWait.Visible = True
lsvwNew.ListItems.Clear
If cboWorlds.ListIndex = 0 Then
Dim aResult() As String, i As Long
aResult = Split(sCodeWorldURLS, "|")
For i = LBound(aResult) To UBound(aResult)
iTimerMinimize = 0
ScanFile FormatNumber(aResult(i), 0)
Next
Else
iTimerMinimize = 0
ScanFile FormatNumber(GetWorldText2ID(cboWorlds.Text), 0)
End If
If lblStandBy.Visible = False Then Unload frmWait
End Sub