0
votes

I am writing an application in VB for windows phone 7.5

but it has some bug

Imports System.IO
Imports System.IO.TextReader
Imports System.Xml
Imports System.Windows.RoutedEventArgs
Imports System.Windows.RoutedEvent
Imports System.ComponentModel
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports Microsoft.Phone.Tasks
Imports System.Xml.Linq 
Imports System.Net.NetworkInformation
Imports Microsoft.VisualBasic.CompilerService

Partial Public Class MainPage
    Inherits PhoneApplicationPage

    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEventArgs)             Handles MyBase.Loaded
        Final.Items.Clear()
        If NetworkInterface.GetIsNetworkAvailable Then
            Dim cl As New WebClient
            AddHandler cl.DownloadStringCompleted, AddressOf cl_DownloadStringCompleted
            cl.DownloadStringAsync(New Uri("http://web.com/xml.xml"))
        Else
            MessageBox.Show("check your internet connection")
        End If
    End Sub


    Private Sub cl_DownloadStringCompleted(sender As Object, e As System.Net.DownloadStringCompletedEventArgs)
        Dim doc = XDocument.Parse(e.Result)
        Dim names = XDocument.Parse(e.Result)
        Dim result_name = names.<Data>.<Entry>
        For Each result In doc.<Data>.<Entry>.<tag>
            Dim item As New ListBoxItem
            item.Content = result.Value
            AddHandler item.Tap, AddressOf ItemTap
            Final.Items.Add(item)
        Next
    End Sub

    Private Sub ItemTap(sender As Object, e As GestureEventArgs)
        Dim lbi As New ListBoxItem
        lbi = sender
        Dim url As New Uri("/" & lbi.Content & ".xaml", UriKind.Relative)
        Me.NavigationService.Navigate(url)
    End Sub

End Class

it finds a bug at Dim url As New Uri("/" & lbi.Content & ".xaml", UriKind.Relative)

and it says on the report :

Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject' is not defined.

NOTE : when i am changing the ItemTap to this : Private Sub ItemTap(ByRef sender As Object, e As GestureEventArgs)

this error is gone and appears another one :

Method 'Private Sub ItemTap(ByRef sender As Object, e As System.Windows.Input.GestureEventArgs)' does not have a signature compatible with delegate 'Delegate Sub EventHandler(Of System.Windows.Input.GestureEventArgs)(sender As Object, e As System.Windows.Input.GestureEventArgs)'.

at line : "AddHandler item.Tap, AddressOf ItemTap"

Any ideas why i have this one ?? thank you !

1

1 Answers

1
votes

You're trying to combine two strings and an object and it can't do this.

I strongly suspect that lbi.Content (in the line that is erroring) is a TextBlock, so your code says "concatenate a string, a TextBlock and a string together".
I suspect that you want the text that is displayed in the TextBlock, so just cast it accordingly:

"/" & DirectCast(lbi.Content, TextBlock).Text & ".xaml"