Hi Stephen!
A quick reply for now:
The function below, removes all non numeric characters (exept "-") from the argument and returns True if the result's format is "-####-####"
(in most provided xml files, the machine name begins with a hyphen)
Code:
Function IsMachineName(ByRef strXMLValue As String) As Boolean
'Returns the strXMLValue with only numeric characters and hyphens.
'Returns True if the strXMLValue after cleaning has the '-####-####' format
Dim i As Integer
Dim c As String * 1
Dim strRet As String
For i = 1 To Len(strXMLValue)
c = Mid$(strXMLValue, i, 1)
If (c Like "[-0-9]") Then
'is a digit or a "-"
strRet = strRet & c
End If
Next i
strXMLValue = strRet
'Adapt the criteria ("-####-####") to your requirements
IsMachineName = (strXMLValue Like "-####-####")
End Function
In your code, could be used as follows:
Code:
MachineName = Mid(text, MachineName + 13, StringLen)
If IsMachineName(MachineName) Then
'You have a valid machinename...
'Import settings...
'[...]
End If
and in the code of frmMachineInfo, just replace the line:
Code:
If Len(strMachineName) < 9 Then
with this:
Code:
If Not IsMachineName(strMachineName) Then
Greetings from Greece,
John