(frm_loadfile)
Option Explicit
Dim xl0a As New Excel.Application
Dim xl0b As Excel.Workbook
Dim xl0s As Excel.Worksheet
Public var As Variant ' variable for project
Public var1 As Variant 'variable for package code
Public var2 As Variant 'variable for parts list version
Private Sub loadwrksht()
Dim X As Integer
Dim xtotal As Integer
Dim counter As Integer
Dim project As String
Dim packagecode As String
Dim plversion As String
Set xl0a = New Excel.Application
Set xl0b = xl0a.Workbooks.Open(txt_filename.Text)
xtotal = xl0b.Worksheets.Count
lst_wrksht.Clear
For counter = 1 To xtotal
Set xl0s = xl0b.Worksheets(counter)
lst_wrksht.AddItem xl0s.Name
Next counter
var = xl0s.Range("A1").Value
var1 = xl0s.Range("A2").Value
var2 = xl0s.Range("C4").Find("rev")
txt_version.Text = var2
project = var
packagecode = var1
plversion = var2
xl0b.Close
xl0a.Quit
Set xl0s = Nothing
Set xl0b = Nothing
Set xl0a = Nothing
End Sub
Function GetVer(tmpStr As String, tmpSpc As String, Mode As String) As String
Dim tmpRetStr As String
Dim tmpLen As Integer
Dim tmpErr As Integer
' *****************************************************
' tmpString = The whole string
' tmpSpc = Space chr
' if mode = "F" then get the string in front of the div
' if mode = "B" then get the string in back of the div
' if mode = "C" then get the string in the middle
'
' Return values:
' Errors
' Err1 = wrong mode ("F" & "B" ok)
' Err2 = No Div, did not found a divider
' Err3 = No F, did not find any string in front of the div
' Err4 = No B, did not find any string in back of the div
' Err5 = No String
' Err6 = No C, did not find any string in the middle
' Normal
' String
' ******************************************************
' Example: GetVer("Red=Green","=","F") will retrun "Red"
' *** for string
tmpErr = 0
If Len(tmpStr) = 0 Then
tmpErr = 5
GoTo GetVerErr
End If
' *** test for chr in tmpDiv
If Len(tmpSpc) = 0 Then
tmpErr = 2
GoTo GetVerErr
' MsgBox ("Error: Non-standard format in saving profile name. No hyphen '-' found.")
' frm_dir.txt_plprofile.Text = "*.plp"
End If
' *** test for div in string
If InStr(1, tmpStr, tmpSpc) = 0 Then
tmpErr = 2
GoTo GetVerErr
' MsgBox ("Error: Non-standard format in saving profile name. No hyphen '-' found.")
' frm_dir.txt_plprofile.Text = "*.plp"
End If
' *** process "F"
If Mode = "F" Then
tmpRetStr = Left(tmpStr, (InStr(1, tmpStr, tmpSpc) - 1))
If Len(tmpRetStr) > 0 Then
GetVer = tmpRetStr
Exit Function
Else
tmpErr = 3
GoTo GetVerErr
End If
End If
tmpErr = 1
frm_dir.txt_plprofile.Text = "*.plp"
'GoTo GetVerErr
Exit Function
GetVerErr:
GetVer = "Err" & tmpErr
End Function