INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

XML

Using an XML startup file instead of an ini file by TomKane
Posted: 15 Apr 03

You should be able to add a reference to your vb project called Microsoft XML, v3.0 - (it might not be that exact version)

Once you do that you can do all kinds of xml parsing or whatever - We have code like this:

Public Sub ReadXMLStartupInfo(strLocalFileName As String)

Dim objXMLDoc As New MSXML2.DOMDocument
Dim objXMLDomNode As MSXML2.IXMLDOMNode
Dim i As Integer
Dim j As Integer
Dim a As String
Dim strErrMessage As String
Dim bRet As Boolean

On Error GoTo Err

    i = InStr(strLocalFileName, "/XML=")
    If i = 0 Then
        strErrMessage = "No XML File Specified, Contact  IT Support"
        GoTo Err
    End If
   
    j = InStr(i + 1, strLocalFileName, "/")
    If j > 0 Then
        a = Mid$(strLocalFileName, i + 5, j - (i + 5))
   Else
        a = Mid$(strLocalFileName, i + 5, Len(strLocalFileName) - i)
    End If
    
    objXMLDoc.async = False
    bRet = objXMLDoc.Load(App.Path & "\" & a)
    If bRet <> True Then
        strErrMessage = "XML File NOT Found" & vbCrLf & App.Path & "\" & strLocalFileName
        GoTo Err
    End If
    If objXMLDoc.parseError.errorCode <> 0 Then
        strErrMessage = "XML Settings not present or not valid."
        GoTo Err
    End If

    Set objXMLDomNode = objXMLDoc.selectSingleNode("/Settings/Server")
    If objXMLDomNode Is Nothing Then
        strErrMessage = "SERVER Setting NOT Present in Startup file."
        GoTo Err
    Else
       strServer = objXMLDomNode.Text
    End If

    Set objXMLDomNode = objXMLDoc.selectSingleNode("/Settings/Database")
    If objXMLDomNode Is Nothing Then
        strErrMessage = "DATABASE Setting NOT Present in Startup file."
        GoTo Err
    Else
        strDatabase = objXMLDomNode.Text
    End If
    
    Set objXMLDomNode = objXMLDoc.selectSingleNode("/Settings/PaymentsServer")
    If objXMLDomNode Is Nothing Then
        strErrMessage = "PAYMENTS SERVER NOT Present in Startup file."
        GoTo Err
    Else
        strPaymentsServer = objXMLDomNode.Text
    End If
    Exit Sub
Err:
    Call MsgBox("Problem with ReadXMLStartupInfo" & vbNewLine & vbNewLine & vbNewLine _
        & "Error Source      = " & Err.Source & vbNewLine _
        & "Error Description = " & Err.Description & vbNewLine _
        & "Error Number      = " & Err.Number & vbNewLine & vbNewLine _
        & "SQL Text          = " & strErrMessage)
    Screen.MousePointer = vbDefault

End Sub

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close