Option Explicit
Private Type Entry
    strFirst As String
    strSecond As String
    strThird As String
End Type
Dim arrEndProduct() As Entry
Dim intArrayCounter As Integer



Private Sub Form_Load(
Dim strTemp As String
Dim intPos As Integer
Dim intPos2 As Integer
Dim intPos3 As Integer
Const SEPARATOR$ = "," 'or Chr$(58) 'substitute for whatever is your separator

Inet1.URL = "qualia.va.com.au/xchangebrowser.txt"
strTemp = Inet1.OpenURL
Text2.Text = strTemp
'read the file and put all the entries into a User-defined Type array called entry,
'set to the variable arrEndProduct(). These and the counter variable, intArrayCounter,
'are defined at module level, but could also be golobal (in a bas file) to be readable from
'other modules
Do
    'add an item to the array using the ReDim command (see: VB Help)
    '(with Preserve keyword to keep all previous entries intact)
    ReDim Preserve arrEndProduct(intArrayCounter)
    With arrEndProduct(intArrayCounter)
        '****** get position of first & second separators and the end of the line
        'get position of separator - start at first character of next entry
        'N.B.intPos3 is zero the first time
        intPos = InStr(intPos3 + 1, strTemp, SEPARATOR)
        'get second separator
        intPos2 = InStr(intPos + 1, strTemp, SEPARATOR)
        'read the bit before the separator N.B. the -1 removes the separator itself
        'this must be done here, before we look for the next end of line, because we
        'need the previous end of line position to determine this
        .strFirst = Mid$(strTemp, intPos3 + 1, intPos - intPos3 - 1)
        'get end of line N.B. vbCRLF is a built in constant for Chr$(10) + Chr$(13)
        'which is the DOS ASCII way of separating lines (CarriageReturn + LineFeed)
        intPos3 = InStr(intPos2 + 1, strTemp, vbCrLf)
        'NOTE if this file is Unix style or was uploaded in binary mode, then
        ' you must change the vbCrLf for vbLf, which is the line-ending in Unix files
        '(no CarriageReturn is used) so here follows safety measure to ensure robust code
        If intPos3 = 0 Then intPos3 = InStr(intPos2 + 1, strTemp, vbLf)
        'now we need to check the last line, which may not have a LF or CRLF
        If intPos3 = 0 Then intPos3 = Len(strTemp) + 1 'note the +1 is necessary, see below
        
        
        'read the bit between the separators - start at one after the last separator
        'end at one before the next
        .strSecond = Mid$(strTemp, intPos + 1, intPos2 - intPos - 1)
        'read the last bit of the line, starting at one after the separator
        'and finishing one before location of CRLF or LF or. possibly, end of text - plus 1
        .strThird = Mid$(strTemp, intPos2 + 1, intPos3 - intPos2 - 1)
        'increment the array counter
        intArrayCounter = intArrayCounter + 1
        'this line below prints the result to the Immediate window
        'so we can see what's happening - it can be remmed out
        Debug.Print .strFirst, .strSecond, .strThird
    End With
    'keep going until there are no more entries
    'this can be checked by looking for any more separators
    'but first, to prevent errors in the Instr function,
    'check if we are at the end of the file, without a CRLF
    If intPos3 = Len(strTemp) + 1 Then Exit Do
    'otherwise loop until there are no more separators
Loop While InStr(intPos3 + 1, strTemp, SEPARATOR) > 0

WebBrowser1.Navigate "http://xchange.re-lab.net"
End Sub


Private Sub Frame1_DblClick()
Form1.Top = 400
Form1.Left = 400
End Sub

Private Sub Frame1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)

End Sub

Private Sub Label1_Click()
WebBrowser1.Navigate "http://www.klari.net/radioqualia"
End Sub

Private Sub Label10_Click()
RealAudio2.DoPlay

End Sub

Private Sub Label11_Click()
RealAudio2.DoStop

End Sub

Private Sub Label13_Click()
If Text1.Text <> "" Then
WebBrowser1.Navigate Text1.Text
End If

End Sub

Private Sub Label17_Click()
Dim strTemp As String
Dim intPos As Integer
Dim intPos2 As Integer
Dim intPos3 As Integer
Dim numberofitems As Integer
Const SEPARATOR$ = "," 'or Chr$(58) 'substitute for whatever is your separator

Inet1.URL = "qualia.va.com.au/xchangebrowser.txt"
strTemp = Inet1.OpenURL
Text2.Text = strTemp
'read the file and put all the entries into a User-defined Type array called entry,
'set to the variable arrEndProduct(). These and the counter variable, intArrayCounter,
'are defined at module level, but could also be golobal (in a bas file) to be readable from
'other modules
Do
    'add an item to the array using the ReDim command (see: VB Help)
    '(with Preserve keyword to keep all previous entries intact)
    ReDim Preserve arrEndProduct(intArrayCounter)
    With arrEndProduct(intArrayCounter)
        '****** get position of first & second separators and the end of the line
        'get position of separator - start at first character of next entry
        'N.B.intPos3 is zero the first time
        intPos = InStr(intPos3 + 1, strTemp, SEPARATOR)
        'get second separator
        intPos2 = InStr(intPos + 1, strTemp, SEPARATOR)
        'read the bit before the separator N.B. the -1 removes the separator itself
        'this must be done here, before we look for the next end of line, because we
        'need the previous end of line position to determine this
        .strFirst = Mid$(strTemp, intPos3 + 1, intPos - intPos3 - 1)
        'get end of line N.B. vbCRLF is a built in constant for Chr$(10) + Chr$(13)
        'which is the DOS ASCII way of separating lines (CarriageReturn + LineFeed)
        intPos3 = InStr(intPos2 + 1, strTemp, vbCrLf)
        'NOTE if this file is Unix style or was uploaded in binary mode, then
        ' you must change the vbCrLf for vbLf, which is the line-ending in Unix files
        '(no CarriageReturn is used) so here follows safety measure to ensure robust code
        If intPos3 = 0 Then intPos3 = InStr(intPos2 + 1, strTemp, vbLf)
        'now we need to check the last line, which may not have a LF or CRLF
        If intPos3 = 0 Then intPos3 = Len(strTemp) + 1 'note the +1 is necessary, see below
        
        
        'read the bit between the separators - start at one after the last separator
        'end at one before the next
        .strSecond = Mid$(strTemp, intPos + 1, intPos2 - intPos - 1)
        'read the last bit of the line, starting at one after the separator
        'and finishing one before location of CRLF or LF or. possibly, end of text - plus 1
        .strThird = Mid$(strTemp, intPos2 + 1, intPos3 - intPos2 - 1)
        'increment the array counter
        intArrayCounter = intArrayCounter + 1
        'this line below prints the result to the Immediate window
        'so we can see what's happening - it can be remmed out
        Debug.Print .strFirst, .strSecond, .strThird
    End With
    'keep going until there are no more entries
    'this can be checked by looking for any more separators
    'but first, to prevent errors in the Instr function,
    'check if we are at the end of the file, without a CRLF
    If intPos3 = Len(strTemp) + 1 Then Exit Do
    'otherwise loop until there are no more separators
Loop While InStr(intPos3 + 1, strTemp, SEPARATOR) > 0


'now we have an array of user type Entry called arrEndProduct
'we can access the array by using dot notation
'e.g. here is the first entry (no. zero) - It's the only entry in your file
'but of course the number 0 can be substituted for any item of the array
'BTW to find the number of items in the array, use
'NumberofItems = UBound(arrEndProduct())
'e.g.
'For intCounter = LBound(arrEndProduct()) To UBound(arrEndProduct())
'etc. to read through the array
numberofitems = UBound(arrEndProduct())

With arrEndProduct(numberofitems)
   Label18.FontUnderline = True
    Label18.Caption = .strFirst
    If Label18.Caption > "" Then
    Label18a.Visible = True
  
    End If
End With

With arrEndProduct(numberofitems - 1)
  Label19.FontUnderline = True
    Label19.Caption = .strFirst
    If Label18.Caption > "" Then
    Label19a.Visible = True
    End If
End With

With arrEndProduct(numberofitems - 2)
  Label20.FontUnderline = True
    Label20.Caption = .strFirst
    If Label18.Caption > "" Then
    Label20a.Visible = True
    End If
End With

End Sub

Private Sub Label18_Click()
Dim numberofitems As Integer
numberofitems = UBound(arrEndProduct())
WebBrowser1.Navigate arrEndProduct(numberofitems).strSecond

End Sub

Private Sub Label18a_Click()
Dim numberofitems As Integer
numberofitems = UBound(arrEndProduct())
WebBrowser1.Navigate arrEndProduct(numberofitems).strThird
End Sub

Private Sub Label19_Click()
Dim numberofitems As Integer
numberofitems = UBound(arrEndProduct())
WebBrowser1.Navigate arrEndProduct(numberofitems - 1).strSecond
End Sub

Private Sub Label19a_Click()
Dim numberofitems As Integer
numberofitems = UBound(arrEndProduct())
WebBrowser1.Navigate arrEndProduct(numberofitems - 1).strThird
End Sub

Private Sub Label2_Click()
WebBrowser1.Navigate "http://orang.orang.org"
End Sub

Private Sub Label20_Click()
Dim numberofitems As Integer
numberofitems = UBound(arrEndProduct())
WebBrowser1.Navigate arrEndProduct(numberofitems - 2).strSecond
End Sub

Private Sub Label20a_Click()
Dim numberofitems As Integer
numberofitems = UBound(arrEndProduct())
WebBrowser1.Navigate arrEndProduct(numberofitems - 2).strThird
End Sub

Private Sub Label3_Click()
WebBrowser1.Navigate "http://www.irational.org/radio/world_service/"
End Sub

Private Sub Label4_Click()
WebBrowser1.Navigate "http://ova.zkm.de"
End Sub

Private Sub Label6_Click()
WebBrowser1.Navigate "http://qualia.va.com.au/xchangebrowser.html"
End Sub



Private Sub Labelend_Click()
End
End Sub

Private Sub Option1_Click()
Option1.Value = True
Option2.Value = False
Option3.Value = False
WebBrowser1.Visible = False
RealAudio2.Visible = True
RealAudio2.Height = 1575 * 4
RealAudio2.Width = 2055 * 4
RealAudio2.Top = 1300
RealAudio2.Left = 3500

End Sub

Private Sub Option2_Click()

Option1.Value = False
Option2.Value = True
Option3.Value = False

WebBrowser1.Visible = False
RealAudio2.Visible = True
RealAudio2.Top = 4000
RealAudio2.Left = 4000
RealAudio2.SetOriginalSize

End Sub

Private Sub Option3_Click()
Option1.Value = False
Option2.Value = False
Option3.Value = True
WebBrowser1.Visible = True
RealAudio2.Visible = True
RealAudio2.Height = 1575
RealAudio2.Width = 2055
RealAudio2.Top = 6240
RealAudio2.Left = 240
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
WebBrowser1.Navigate Text1.Text
End If
End Sub

Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
Dim a, b, c, ova As Integer
Dim ram As String
Dim check As Variant

check = Mid$(URL, Len(URL) - 4, 4)
a = InStr(check, ".ram")
b = InStr(check, ".ra")
c = InStr(check, ".rm")

If InStr(URL, "perl/ova-raplayer?") > 0 Then
RealAudio2.Source = URL
RealAudio2.Visible = True
Cancel = True
RealAudio2.DoPlay
End If


If a > 0 Then
RealAudio2.Source = URL
RealAudio2.Visible = True
Cancel = True
RealAudio2.DoPlay
End If

If b > 0 Then
RealAudio2.Source = URL
RealAudio2.Visible = True
Cancel = True
RealAudio2.DoPlay

End If

If c > 0 Then
RealAudio2.Source = URL
RealAudio2.Visible = True
Cancel = True
RealAudio2.DoPlay

End If



End Sub