Fout is asp.net code (C# -> VB)

Pagina: 1
Acties:
  • 39 views sinds 30-01-2008

  • Rhapsody
  • Registratie: Oktober 2002
  • Laatst online: 23:10

Rhapsody

In Metal We Trust

Topicstarter
Hey, ik heb deze code proberen om te zetten naar VB.NET code:

C#:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
protected DataSet LoadMyPBData()
    {
      string sourceXml = Server.MapPath("Tutorials.xml");
      DataSet dataSet = new DataSet();
      try
      {
         dataSet.ReadXml(sourceXml);
      }
      catch (Exception e)
      {
         ErrorMessage.Text = e.Message;
         dataSet = null;
      }
      return dataSet;
    }



VB:

code:
1
2
3
4
5
6
7
8
9
10
11
12
function LoadMyPBData()
    dim sourceXML as string
    sourceXML = Server.MapPath("Tutorials.xml")
    dim dataSet as new DataSet()
    try
        dataSet.ReadXml(sourceXml)
    Catch(e as Exception)
        ErrorMessage.Text = e.Message
        dataSet = null
    end try
    return dataSet
end function


Nu geeft hij de volgende fout als ik de VB code test:

BC30205: End of statement expected.

en die fout zit dus op deze regel:

code:
1
2
3
    try
        dataSet.ReadXml(sourceXml)
    Catch(e as Exception)



Kan iemand mij vertellen waar de fout zit?

🇪🇺 pro Europa!


  • whoami
  • Registratie: December 2000
  • Nu online
Check ff de SDK help hoe je die try / catch schrijft. Met een beetje moeite moet je syntax errors zelf kunnen oplossen.
GoT is geen helpdesk.

Uit de .NET framework help:
Example
The following simplified example illustrates the structure of the Try…Catch…Finally statement:
code:
1
2
3
4
5
6
7
8
9
10
11
Public Sub TryExample()
   Dim x As Integer = 5   ' Declare variables.
   Dim y As Integer = 0
   Try   ' Set up structured error handling.
      x /= y   ' Cause a "Divide by Zero" error.
   Catch ex As Exception When y = 0   ' Catch the error.
      MsgBox(ex.toString)   ' Show friendly error message.
   Finally
      Beep()   ' Beep after error processing.
   End Try
End Sub

https://fgheysels.github.io/


Dit topic is gesloten.