diff --git a/crypt.vb b/crypt.vb index 9567bdb..a342549 100644 --- a/crypt.vb +++ b/crypt.vb @@ -1,6 +1,7 @@ Imports System.IO Imports System.Security.Cryptography Imports System.Text +Imports System.Text.RegularExpressions Public Class crypt Public Shared Function FEncS$(ByVal X$, ByVal Jco0$, ByVal Jcd0$, ByVal Xs0 As Long) @@ -560,4 +561,71 @@ Public Class crypt Return Encoding.UTF8.GetString(ms.ToArray()) End Function + Public Shared Function DescomponerCNsuscriptor(CNsuscriptor As String, + Optional ByRef nombre As String = Nothing, + Optional ByRef docIdentidad As String = Nothing, + Optional ByRef numPersonal As String = Nothing) As Boolean + + nombre = CNsuscriptor + docIdentidad = Nothing + numPersonal = Nothing + + If String.Compare(CNsuscriptor, "", False) = 0 Then + Return False + End If + + Dim text As String = Nothing + Dim text2 As String = Nothing + Dim array() As String = Regex.Split(CNsuscriptor, " DI=") + + If array.Length > 2 Then + Return False + End If + + Dim text3 As String + + If array.Length = 2 Then + text3 = array(0) + array = Regex.Split(array(1), " N=") + + If array.Length > 2 Then + Return False + End If + + text = array(0) + If array.Length = 2 Then + text2 = array(1) + End If + Else + array = Regex.Split(CNsuscriptor, " N=") + + If array.Length > 2 Then + Return False + End If + + text3 = array(0) + If array.Length = 2 Then + text2 = array(1) + End If + End If + + If String.IsNullOrWhiteSpace(text3) OrElse text3.Contains("=") Then + Return False + End If + + If text IsNot Nothing AndAlso (String.IsNullOrWhiteSpace(text.Trim()) OrElse text.Contains("=")) Then + Return False + End If + + If text2 IsNot Nothing AndAlso (String.IsNullOrWhiteSpace(text2.Trim()) OrElse text2.Contains("=")) Then + Return False + End If + + nombre = text3 + docIdentidad = text + numPersonal = text2 + Return True + End Function + + End Class \ No newline at end of file diff --git a/tsUtilidades.vbproj b/tsUtilidades.vbproj index 3d7edfa..86c160c 100644 --- a/tsUtilidades.vbproj +++ b/tsUtilidades.vbproj @@ -16,11 +16,12 @@ net8.0 tsUtilidades net8.0, libreria - 1.0.9 + 1.0.10 Manuel Tecnosis S.A - Utilidades varias Entity Framework compatibles con EF Core 8. + Utilidades Varias + - 2025-07-28 1.0.10 Nueva función DescomponerCNsuscriptor - 2025-07-28 1.0.9 Correccion ObtenerValorDesdeNombre - 2025-07-28 1.0.8 Correccion ObtenerValorDesdeNombre - 2025-07-28 1.0.7 Nueva función de ObtenerValorDesdeNombre