Ringrazio tutti per l'aiuto, mi scuso se ho creato confusione, comunque ho risolto con il seguente codice (completo), optando per la soluzione con Regex:
Private Sub Carica_File()
Dim readText() As String = File.ReadAllLines(dirApplicationData & "\Preferenze.tfm")
Dim CartPregeoConfig As String = readText(2) & "EXE\"
Dim FilePregeoConfig As String = "Pregeo.config"
Dim incr As Integer
Dim PosNomeR As Integer
Dim righe() As String = File.ReadAllLines(CartPregeoConfig & FilePregeoConfig)
Dim reg As Match
Me.Text = "Configurazione del file " & CartPregeoConfig & FilePregeoConfig
For Each currentRow As String In righe
If currentRow = "" Or Mid(currentRow, 1, 1) = ";" Then Continue For
incr += 1
If currentRow.IndexOf("[DATI REDATTORE]", StringComparison.OrdinalIgnoreCase) >= 0 Then PosNomeR = incr + 2
Dim Posuguale As Integer = InStr(currentRow, "=")
'Tabella Font
reg = Regex.Match(currentRow, "NomeFontPol", RegexOptions.IgnoreCase)
If reg.Success Then
TBNomeFontPol.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "NumMaxRighePol", RegexOptions.IgnoreCase)
If reg.Success Then
TBNumMaxRighePol.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "NomeFont", RegexOptions.IgnoreCase)
If reg.Success Then
TBNomeFont.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "NumMaxRighe", RegexOptions.IgnoreCase)
If reg.Success Then
TBNumMaxRighe.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
'Tabella DISCHI
reg = Regex.Match(currentRow, "FILE_DISTANZETAF", RegexOptions.IgnoreCase)
If reg.Success Then
TBFileDistTaf.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "DskAPPLexe", RegexOptions.IgnoreCase)
If reg.Success Then
TBDskAPPLexe.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "DskAPPLada", RegexOptions.IgnoreCase)
If reg.Success Then
TBDskAPPLada.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "DskAPPLtmp", RegexOptions.IgnoreCase)
If reg.Success Then
TBDskAPPLtmp.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
'Tabella Plus
reg = Regex.Match(currentRow, "Plus", RegexOptions.IgnoreCase)
If reg.Success Then
TBPlus.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "calcolo esteso", RegexOptions.IgnoreCase)
If reg.Success Then
TBCalcoloEsteso.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
'Tabella Versione
reg = Regex.Match(currentRow, "Versione", RegexOptions.IgnoreCase)
If reg.Success Then
TBVersione.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "Data", RegexOptions.IgnoreCase)
If reg.Success Then
TBData.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
'Tabella Dati redattore
reg = Regex.Match(currentRow, "sigla prov.", RegexOptions.IgnoreCase)
If reg.Success Then
TBSigla_Prov.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
If PosNomeR > 0 Then
reg = Regex.Match(currentRow, "\bnome\b", RegexOptions.IgnoreCase)
If reg.Success Then
TBNome.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
End If
reg = Regex.Match(currentRow, "cognome", RegexOptions.IgnoreCase)
If reg.Success Then
TBCognome.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "qualifica", RegexOptions.IgnoreCase)
If reg.Success Then
CBoxQualifica.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
If PosNomeR > 0 Then
reg = Regex.Match(currentRow, "provincia", RegexOptions.IgnoreCase)
If reg.Success Then
TBProvincia.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
PosNomeR = 0
End If
End If
reg = Regex.Match(currentRow, "numero", RegexOptions.IgnoreCase)
If reg.Success Then
TBNumero.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
reg = Regex.Match(currentRow, "codc", RegexOptions.IgnoreCase)
If reg.Success Then
TBCodiceFiscale.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
'Tabella LAST PROT
reg = Regex.Match(currentRow, "ultimoprot", RegexOptions.IgnoreCase)
If reg.Success Then
TBUltimoProt.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
'Tabella PROV DI COMPETENZA
reg = Regex.Match(currentRow, "provincia", RegexOptions.IgnoreCase)
If reg.Success Then
If Len(currentRow) = 12 Then
TBProvComp.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
End If
'Tabella DATI TECNICO
If PosNomeR = 0 Then
reg = Regex.Match(currentRow, "\bnome\b", RegexOptions.IgnoreCase)
If reg.Success Then
TBNomeTecnico.Text = currentRow.Substring(Posuguale, Len(currentRow) - Posuguale)
End If
End If
Next
End Sub
il contenuto del file Pregeo.config è variabile, il file che ho utilizzato nel codice è così costituito:
[Font]
NomeFontPol = COURIER New
NumMaxRighePol = 90
NomeFont = COURIER New
NumMaxRighe = 65
[DISCHI]
DskAPPLexe=C:
DskAPPLada=C:
DskAPPLtmp=C:
[Plus]
Plus = S
calcolo esteso = S
[Versione]
Versione = 10.00
Data=13/02/2025
[DATI REDATTORE]
sigla prov.=XX
nome=PINCO
cognome=PALLINO
qualifica=PERITO
provincia=XXXXXX
numero=5215
codc=PNCPLL60D12A80L
[LAST_PROT]
ultimoprot=202545
[PROV_DI_COMP]
provincia=XX
[DATI TECNICO]
nome=PALLINO PINCO
Saluti
Giorgio