'Contoh untuk CommonDialog Open
Private Sub Command1_Click()
On Error GoTo ErrHandler
Dim strPath As String
With CommonDialog1
.CancelError = True
.Flags = cdlOFNHideReadOnly
.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
.FilterIndex = 2
.DialogTitle = "Open File"
.ShowOpen
strPath = .FileName
End With
'Code selanjutnya
Exit Sub
ErrHandler:
Exit Sub
End Sub
'Contoh untuk CommonDialog Save As
Private Sub Command2_Click()
On Error GoTo ErrHandler
Dim strPath As String
With CommonDialog1
.CancelError = True
.Flags = cdlOFNHideReadOnly
.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
.FilterIndex = 2
.DialogTitle = "Save As"
.ShowSave
strPath = .FileName
End With
'Code selanjutnya
Exit Sub
ErrHandler:
Exit Sub
End Sub
'Contoh untuk CommonDialog Save
Private Sub Command3_Click()
On Error GoTo ErrHandler
Dim strPath As String
With CommonDialog1
.CancelError = True
.Flags = cdlOFNHideReadOnly
.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
.FilterIndex = 2
.DialogTitle = "Save"
.ShowSave
strPath = .FileName
End With
'Code selanjutnya
Exit Sub
ErrHandler:
Exit Sub
End Sub
Sunday, June 17, 2012
Contoh Menggunakan CommonDialog Open Save As
Labels:
Dialog
Membaca File Binary Dengan Visual Basic 6.0
Option Explicit
Private Sub Command1_Click()
Open "C:\Documents and Settings\Admin\My Documents\Blogger VB6\Blogger\4basic-vb.xml" For Binary As #1
Dim strBuff As String
strBuff = Space(LOF(1))
Get #1, , strBuff
Close #1
Text1.Text = strBuff
End Sub
Labels:
File-And-Folder
XML Pretty Print - Merapikan Format File XML
Private Sub PrettyPrint(Parent As IXMLDOMNode, Optional Level As Integer)
Dim Node As IXMLDOMNode
Dim Indent As IXMLDOMText
If Not Parent.ParentNode Is Nothing And Parent.ChildNodes.Length > 0 Then
For Each Node In Parent.ChildNodes
Set Indent = Node.OwnerDocument.createTextNode(vbNewLine & String(Level, vbTab))
If Node.NodeType = NODE_TEXT Then
If Trim(Node.Text) = "" Then
Parent.RemoveChild Node
End If
ElseIf Node.PreviousSibling Is Nothing Then
Parent.InsertBefore Indent, Node
ElseIf Node.PreviousSibling.NodeType <> NODE_TEXT Then
Parent.InsertBefore Indent, Node
End If
Next Node
End If
If Parent.ChildNodes.Length > 0 Then
For Each Node In Parent.ChildNodes
If Node.NodeType <> NODE_TEXT Then PrettyPrint Node, Level + 1
Next Node
End If
End Sub
Labels:
XML-VB6
XML Tidy - Untuk Merapikan File XML
Public Function PrettyPrintXML(XML As String) As String
Dim Reader As New SAXXMLReader60
Dim Writer As New MXXMLWriter60
Writer.Indent = True
Writer.standalone = False
Writer.omitXMLDeclaration = False
Writer.encoding = "utf-8"
Set Reader.contentHandler = Writer
Set Reader.dtdHandler = Writer
Set Reader.errorHandler = Writer
Call Reader.putProperty("http://xml.org/sax/properties/declaration-handler", _
Writer)
Call Reader.putProperty("http://xml.org/sax/properties/lexical-handler", _
Writer)
Call Reader.parse(XML)
PrettyPrintXML = Writer.output
End Function
Public Function PrettyPrintDocument(Doc As DOMDocument60) As String
PrettyPrintDocument = PrettyPrintXML(Doc.XML)
End Function
Labels:
XML-VB6
Subscribe to:
Posts
(
Atom
)