O
Orion Tatsihama
Guest
Thank you so much! Ill try that the first chance I get...stupid homework.
Public Class OpenForInput
Private strFile As String
Private intHandle As Integer
Private strData As String
Private strError As String
Public Property FileName() As String
Get
Return strFile
End Get
Set(ByVal Value As String)
strFile = Value
If Dir(strFile) = "" Then
strError = "File " & strFile & " not found."
Exit Property
End If
Dim lngLength As Long
lngLength = FileLen(strFile)
strError = ""
strData = ""
intHandle = FreeFile()
Try
FileOpen(intHandle, strFile, OpenMode.Input, OpenAccess.Read, OpenShare.Default, )
strData = InputString(intHandle, lngLength)
Catch aru As System.ArgumentException
strError = aru.Message
Catch ios As System.IO.IOException
strError = ios.Message
Catch exe As Exception
strError = exe.Message
Finally
FileClose(intHandle)
If strError > "" Then had an error
If strData = "" Then means couldnt read file
strError = "Couldnt read file. " & Chr(13) & strError
Else
strError = "Couldnt open file. " & Chr(13) & strError
End If
End If
End Try
End Set
End Property
Public ReadOnly Property ErrorMessage() As String
Get
Return strError
End Get
End Property
Public ReadOnly Property FileData() As String
Get
Return strData
End Get
End Property
End Class
Public Class Form
Inherits System.Windows.Forms.Form
Public DVlog As New DataSet()
Dim xmlDoc As New Xml.XmlDataDocument()
[ Windows Form Designer generated code ]
DVlog.ReadXml(fileOpen)
Private Sub saveXMLFile()
Dim sDialog As New SaveFileDialog()
sDialog.FileName = ("DVconfig") & ".xml"
sDialog.Filter = "XML files (*.xml)|*.xml"
If sDialog.ShowDialog = DialogResult.OK Then
Dim wstream As New _
System.IO.StreamWriter(sDialog.FileName)
DVlog.WriteXml(wstream, XmlWriteMode.WriteSchema)
wstream.Close()
End If
End Sub
ViewDVlog.datasource = ds1
ViewDVlog.readonly = true
Dim fsReadXml As New System.IO.FileStream("DVconfig.xml", System.IO.FileMode.Open)
Create an XmlTextReader to read the file.
Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml)
Read the XML document into the DataSet.
DVblog.ReadXml(myXmlReader)
Close the XmlTextReader
myXmlReader.Close()
End Class
Private Sub saveXMLFile()
DVlog.ReadXml(fileOpen)
Dim sDialog As New SaveFileDialog()
sDialog.FileName = ("DVconfig") & ".xml"
sDialog.Filter = "XML files (*.xml)|*.xml"
If sDialog.ShowDialog = DialogResult.OK Then
Dim wstream As New _
System.IO.StreamWriter(sDialog.FileName)
DVlog.WriteXml(wstream, XmlWriteMode.WriteSchema)
wstream.Close()
End If
End Sub
ViewDVlog.datasource = ds1
ViewDVlog.readonly = true
Dim fsReadXml As New System.IO.FileStream("DVconfig.xml", System.IO.FileMode.Open)
Create an XmlTextReader to read the file.
Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml)
Read the XML document into the DataSet.
DVblog.ReadXml(myXmlReader)
Close the XmlTextReader
myXmlReader.Close()
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fsReadXml As New System.IO.FileStream("DVconfig.xml", System.IO.FileMode.Open)
Create an XmlTextReader to read the file.
Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml)
Read the XML document into the DataSet.
DVlog.ReadXml(myXmlReader)
Close the XmlTextReader
myXmlReader.Close()
End Sub
ViewDVlog.datasource = ds1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[U]ViewDVlog.datasource = ds1[/U]
Dim fsReadXml As New System.IO.FileStream("DVconfig.xml", System.IO.FileMode.Open)
Create an XmlTextReader to read the file.
Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml)
Read the XML document into the DataSet.
DVlog.ReadXml(myXmlReader)
Close the XmlTextReader
myXmlReader.Close()
End Sub
Private Sub saveXMLFile()
DVlog.ReadXml(FileOpen)
Dim sDialog As New SaveFileDialog()
sDialog.FileName = ("DVconfig") & ".xml"
sDialog.Filter = "XML files (*.xml)|*.xml"
If sDialog.ShowDialog = DialogResult.OK Then
Dim wstream As New _
System.IO.StreamWriter(sDialog.FileName)
DVlog.WriteXml(wstream, XmlWriteMode.WriteSchema)
wstream.Close()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DVlog.ReadXml(xmlSchema.xsd)
End Sub
Public Class Form
Inherits System.Windows.Forms.Form
Public DVlog As New DataSet()
Dim xmlDoc As New Xml.XmlDataDocument()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
This call is required by the Windows Form Designer.
InitializeComponent()
Add any initialization after the InitializeComponent() call
End Sub
Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
NOTE: The following procedure is required by the Windows Form Designer
It can be modified using the Windows Form Designer.
Do not modify it using the code editor.
Friend WithEvents Cancel As System.Windows.Forms.Button
Friend WithEvents Submit As System.Windows.Forms.Button
Friend WithEvents DVDProps As System.Windows.Forms.GroupBox
Friend WithEvents Comments As System.Windows.Forms.TextBox
Friend WithEvents Year As System.Windows.Forms.TextBox
Friend WithEvents SE As System.Windows.Forms.ComboBox
Friend WithEvents Disks As System.Windows.Forms.TextBox
Friend WithEvents Length As System.Windows.Forms.TextBox
Friend WithEvents Rating As System.Windows.Forms.ComboBox
Friend WithEvents Title As System.Windows.Forms.TextBox
Friend WithEvents Genre As System.Windows.Forms.TextBox
Friend WithEvents CommentsLabel As System.Windows.Forms.Label
Friend WithEvents YearLabel As System.Windows.Forms.Label
Friend WithEvents SELabel As System.Windows.Forms.Label
Friend WithEvents DisksLabel As System.Windows.Forms.Label
Friend WithEvents LengthLabel As System.Windows.Forms.Label
Friend WithEvents RatingLabel As System.Windows.Forms.Label
Friend WithEvents TitleLabel As System.Windows.Forms.Label
Friend WithEvents GenreLabel As System.Windows.Forms.Label
Friend WithEvents ViewDVlog As System.Windows.Forms.DataGrid
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Cancel = New System.Windows.Forms.Button()
Me.Submit = New System.Windows.Forms.Button()
Me.DVDProps = New System.Windows.Forms.GroupBox()
Me.Comments = New System.Windows.Forms.TextBox()
Me.Year = New System.Windows.Forms.TextBox()
Me.SE = New System.Windows.Forms.ComboBox()
Me.Disks = New System.Windows.Forms.TextBox()
Me.Length = New System.Windows.Forms.TextBox()
Me.Rating = New System.Windows.Forms.ComboBox()
Me.Title = New System.Windows.Forms.TextBox()
Me.Genre = New System.Windows.Forms.TextBox()
Me.CommentsLabel = New System.Windows.Forms.Label()
Me.YearLabel = New System.Windows.Forms.Label()
Me.SELabel = New System.Windows.Forms.Label()
Me.DisksLabel = New System.Windows.Forms.Label()
Me.LengthLabel = New System.Windows.Forms.Label()
Me.RatingLabel = New System.Windows.Forms.Label()
Me.TitleLabel = New System.Windows.Forms.Label()
Me.GenreLabel = New System.Windows.Forms.Label()
Me.ViewDVlog = New System.Windows.Forms.DataGrid()
Me.Button1 = New System.Windows.Forms.Button()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.DVDProps.SuspendLayout()
CType(Me.ViewDVlog, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
[I took out a bunch of Form Designer code to shorten message]
RatingLabel
Me.RatingLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.RatingLabel.Location = New System.Drawing.Point(192, 72)
Me.RatingLabel.Name = "RatingLabel"
Me.RatingLabel.Size = New System.Drawing.Size(40, 16)
Me.RatingLabel.TabIndex = 3
Me.RatingLabel.Text = "Rating"
TitleLabel
Me.TitleLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.TitleLabel.Location = New System.Drawing.Point(8, 72)
Me.TitleLabel.Name = "TitleLabel"
Me.TitleLabel.Size = New System.Drawing.Size(32, 16)
Me.TitleLabel.TabIndex = 2
Me.TitleLabel.Text = "Title"
GenreLabel
Me.GenreLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.GenreLabel.Location = New System.Drawing.Point(8, 32)
Me.GenreLabel.Name = "GenreLabel"
Me.GenreLabel.Size = New System.Drawing.Size(40, 16)
Me.GenreLabel.TabIndex = 1
Me.GenreLabel.Text = "Genre"
ViewDVlog
Me.ViewDVlog.DataMember = ""
Me.ViewDVlog.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.ViewDVlog.Location = New System.Drawing.Point(360, 8)
Me.ViewDVlog.Name = "ViewDVlog"
Me.ViewDVlog.Size = New System.Drawing.Size(368, 416)
Me.ViewDVlog.TabIndex = 10
Button1
Me.Button1.Location = New System.Drawing.Point(168, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(72, 32)
Me.Button1.TabIndex = 11
Me.Button1.Text = "Refresh"
GroupBox1
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Cancel, Me.Submit, Me.Button1})
Me.GroupBox1.Location = New System.Drawing.Point(56, 368)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(248, 56)
Me.GroupBox1.TabIndex = 12
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Controls"
Form
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(736, 430)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1, Me.ViewDVlog, Me.DVDProps})
Me.Name = "Form"
Me.Text = "DVLog"
Me.DVDProps.ResumeLayout(False)
CType(Me.ViewDVlog, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
Dataset
ViewDVlog.DataSource = DVlog
ViewDVlog.ReadOnly = True
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DVlog.ReadXml("xmlSchema.xsd")
ViewDVlog.DataSource = DVlog
ViewDVlog.ReadOnly = True
End Sub