tincho 12-08-2021, 11:13
Hola a todos.
Aquí les propongo una función que genera una cadena de texto para marca temporal.
Por favor si alguien tiene una mejor idea por favor no dude en compartirla.

Código:
'' Returns a text string over time in "yyyymmddhhnnss" format. From years to seconds.

Static Public Function Timestamp(datTime As Date) As String
 
  Return Format(datTime, "yyyymmddhhnnss")
 
End
Saludos.
tincho 12-08-2021, 11:07
Hola a todos.
Aquí les propongo una función que formatea un texto en párrafos, opcionalmente se puede indicar "html5" para que agregue los tags  <p></p>.
Por favor si alguien tiene una mejor idea por favor no dude en compartirla.
Código:
'' Paragraph validation, double space NO, Space at the beginning and/or at the end NO, line breaks at the beginning and/or at the end NO etc.

Public Function Paragraph(strInput As String, Optional strMod As String) As String
 
  Dim strOut As String
  Dim strTmp As String
  Dim int As Integer
  Dim stxLines As New String[] ' List of lines as they come in txt
  Dim str As String
  Dim strCap As String
  Dim strParagraph As String
  Dim stxParagraph As New String[]
  '
  strTmp = Replace(strInput, "\n ", "\n")
  strTmp = Replace(strInput, "\n\n", "\n")
  strTmp = Replace(strInput, "\t\n", "\n")
  strTmp = Replace(strInput, "\n\t", "\n")
 
  ' Work by paragraph
  strParagraph = ""
 
  For int = 0 To stxLines.Max
    If stxLines[int] <> "" Then
      str = String.Trim(stxLines[int])
      strCap = String.Left(str)
      Select int
        Case 0
          stxParagraph.Add(str)
        Case Else
          If String.UCase(strCap) = strCap Then
            stxParagraph.Add(str)
          Else
            stxParagraph[stxParagraph.Max] = stxParagraph[stxParagraph.Max] & " " & str
          Endif
      End Select
    Endif
  Next
 
  Select String.LCase(strMod)
    Case "html", "html5"
      For int = 0 To stxParagraph.Max
        ' Proceed to validate the characters, in this case for XHTML 1.0
        strParagraph = XmlValidate(stxParagraph[int], "utf8")
        strParagraph = ReTager(strParagraph)
        If InStr(strParagraph, "<h") > 0 Then
          stxParagraph[int] = "\n" & strParagraph & "\n"
        Else
          stxParagraph[int] = "<p>" & strParagraph & "</p>"
        Endif
        
      Next
  End Select
 
  strOut = stxParagraph.Join("\n")
 
  Return strOut
 
End
Saludos.
tincho 12-08-2021, 10:59
Hola a todos.
Aquí les propongo una función que adecua un texto para que sea posible usarlo en una consulta SQL si que esta de error.
Por favor si alguien tiene una mejor idea por favor no dude en compartirla.

Código:
'' Returns a text suitable for SQL queries, removes line breaks and characters not compatible with SQL statements.

Static Public Function Chek4SQL(strInput As String) As String
 
  Dim strOutput As String
 
  strOutput = Replace(strInput, Chr(92) & Chr(110), ":")
  strOutput = Replace(strOutput, Chr(34), "")
  strOutput = Replace(strOutput, "\n", " ")
  strOutput = Replace(strOutput, "\r", "")
  strOutput = Replace(strOutput, "\x00", "")
  strOutput = Replace(strOutput, Chr(39), Chr(46))
  strOutput = Replace(strOutput, Chr(44), Chr(46))
 
  Return strOutput
 
End
Saludos.
Páginas (553):    1 395 396 397 398 399 553   
Bienvenido, Invitado
Tienes que registrarte para poder participar en nuestro foro.
Recordarme?
Miembros: 280
Último miembro: herbert
Temas del foro: 1,704
Mensajes del foro: 8,843
Últimos temas
Error de sistema "Demasia...
Foro: General
Último mensaje por: chescobar, Hace 4 horas
Respuestas: 0 - Vistas: 13
controlar el Activado/Des...
Foro: General
Último mensaje por: atakito, Hace 9 horas
Respuestas: 0 - Vistas: 19
Conexión Bluetooth: RFCOM...
Foro: Hardware & IoT
Último mensaje por: jguardon, 06-05-2025, 16:57
Respuestas: 5 - Vistas: 161
gb.db2: columnas calculad...
Foro: Bases de Datos
Último mensaje por: guizans, 04-05-2025, 21:02
Respuestas: 14 - Vistas: 536
Powered By MyBB, © 2002-2025 MyBB Group.
Made with by Curves UI.