У меня есть этот код:
Public Class Transform
Dim inputFile As IO.StringReader ' Object variable
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ofdOpenFile.FileOk
' Configure the Open dialog box and display it.
With ofdOpenFile
.Filter = " Text files (*. txt)|*. txt| All files (*.*)|*.*"
.InitialDirectory = " C:\ Data"
.Title = " Select a File to Open"
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
inputFile = IO.File.OpenText(.FileName)
End If
End With
End Sub
Private Sub Transform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Option Strict On
Imports System.Xml.Xsl
''' <summary>
''' Updated 10.14.2010 - changed class name to Form1
''' This program converts a VB 2008 XML Documentation
''' into an HTML file for displaying in a browser using
''' an XSLT transformation file stored on a remote server
''' </summary>
''' <author>John Couture - jcouture@sdccd.edu</author>
''' <assignment>Week 5</assignment>
''' <version>2.02 - 02/03/2010</version>
''' <seealso>http://media.techtarget.com/digitalguide/images/Misc/professionalVB_ch12.pdf </seealso>
''' <seealso>Using XML in Visual Basic 2005,
''' Excerpted from Wrox Publishing: Professional VB 2005,
''' (c)2005, Bill Evjen et al, ISBN 0-764507536-8
''' </seealso>
'''
Public Class Form1
' Identify where the XSLT file is located
Dim strTransformPath As String = Application.StartupPath & "\transform.xslt"
' Provide a default file name for this program
Dim strOutputPath As String = _
Application.StartupPath & "/output.htm"
''' <summary>
''' When the program first starts, show the user where the output
''' file will be located.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
End Sub
Private Sub Transform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtHTML.Text = strOutputPath
End Sub
''' <summary>
''' Using a file dialog box, get the input file.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnXML_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnXML.Click
With ofdOpenFile
.InitialDirectory = "C:\"
.Filter() = "Comment File | *.xml"
.ShowDialog()
txtXML.Text = .FileName
End With
End Sub
''' <summary>
''' Transform the XML code into HTML code
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks>
''' Once you know the location of the XML file, the computer
''' will automatically download the XSLT (transformation) file
''' and convert the XML code into HTML code for printing.
''' </remarks>
Private Sub btnTransform_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnTransform.Click
Dim myXSLTransform As XslCompiledTransform = New XslCompiledTransform
Try
'myXSLTransform.Load(txtXSLT.Text)
myXSLTransform.Load(strTransformPath)
myXSLTransform.Transform(txtXML.Text, txtHTML.Text)
btnTransform.Text = "Transformation is Done!"
btnTransform.BackColor = System.Drawing.Color.Green
btnTransform.ForeColor = System.Drawing.Color.White
btnTransform.Font = New Font(btnTransform.Name, 12, FontStyle.Bold)
Catch ex As Exception
If Not IO.File.Exists(strTransformPath) Then
MessageBox.Show("Cannot find XSL file")
End If
If Not IO.File.Exists(txtXML.Text) Then
MessageBox.Show("Cannot find XML file")
End If
MessageBox.Show("Message: " & ex.Message)
End Try
End Sub
End Class
И я получаю следующие ошибки:
'Private Sub Transform_Load (отправитель как объект, e как System.EventArgs)' имеетнесколько определений с одинаковыми подписями.Строка 15
'strOutputPath' не объявлена.Может быть недоступен из-за уровня защиты.Строка 51
Тип 'XslCompiledTransform' не определен.Строка 83
Public Class Transform
Dim inputFile As IO.StringReader ' Object variable
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ofdOpenFile.FileOk
' Configure the Open dialog box and display it.
With ofdOpenFile
.Filter = " Text files (*. txt)|*. txt| All files (*.*)|*.*"
.InitialDirectory = " C:\ Data"
.Title = " Select a File to Open"
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
inputFile = IO.File.OpenText(.FileName)
End If
End With
End Sub
Private Sub Transform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Option Strict On
Imports System.Xml.Xsl
''' <summary>
''' Updated 10.14.2010 - changed class name to Form1
''' This program converts a VB 2008 XML Documentation
''' into an HTML file for displaying in a browser using
''' an XSLT transformation file stored on a remote server
''' </summary>
''' <author>John Couture - jcouture@sdccd.edu</author>
''' <assignment>Week 5</assignment>
''' <version>2.02 - 02/03/2010</version>
''' <seealso>http://media.techtarget.com/digitalguide/images/Misc/professionalVB_ch12.pdf </seealso>
''' <seealso>Using XML in Visual Basic 2005,
''' Excerpted from Wrox Publishing: Professional VB 2005,
''' (c)2005, Bill Evjen et al, ISBN 0-764507536-8
''' </seealso>
'''
Public Class Form1
' Identify where the XSLT file is located
Dim strTransformPath As String = Application.StartupPath & "\transform.xslt"
' Provide a default file name for this program
Dim strOutputPath As String = _
Application.StartupPath & "/output.htm"
''' <summary>
''' When the program first starts, show the user where the output
''' file will be located.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
End Sub
Private Sub Transform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtHTML.Text = strOutputPath
End Sub
''' <summary>
''' Using a file dialog box, get the input file.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnXML_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnXML.Click
With ofdOpenFile
.InitialDirectory = "C:\"
.Filter() = "Comment File | *.xml"
.ShowDialog()
txtXML.Text = .FileName
End With
End Sub
''' <summary>
''' Transform the XML code into HTML code
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks>
''' Once you know the location of the XML file, the computer
''' will automatically download the XSLT (transformation) file
''' and convert the XML code into HTML code for printing.
''' </remarks>
Private Sub btnTransform_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnTransform.Click
Dim myXSLTransform As XslCompiledTransform = New XslCompiledTransform
Try
'myXSLTransform.Load(txtXSLT.Text)
myXSLTransform.Load(strTransformPath)
myXSLTransform.Transform(txtXML.Text, txtHTML.Text)
btnTransform.Text = "Transformation is Done!"
btnTransform.BackColor = System.Drawing.Color.Green
btnTransform.ForeColor = System.Drawing.Color.White
btnTransform.Font = New Font(btnTransform.Name, 12, FontStyle.Bold)
Catch ex As Exception
If Not IO.File.Exists(strTransformPath) Then
MessageBox.Show("Cannot find XSL file")
End If
If Not IO.File.Exists(txtXML.Text) Then
MessageBox.Show("Cannot find XML file")
End If
MessageBox.Show("Message: " & ex.Message)
End Try
End Sub
End Class
И я получаю следующие ошибки:
«Private Sub Transform_Load (отправитель как объект, e как System.EventArgs)» имеет несколько определений сидентичные подписи.Строка 15
'strOutputPath' не объявлена.Может быть недоступен из-за уровня защиты.Строка 51
Тип 'XslCompiledTransform' не определен.Линия 83