Ver Mensaje Individual
  #3 (permalink)  
Antiguo 13/06/2005, 15:24
Avatar de GeoAvila
GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 5 meses
Puntos: 53
seria algo asi..
Código:
' Put quotes around a string and double any embedded Chr$(34)
' Codigo hecho por Francesco Balena
' convert all control characters into embedded VB constants
' or CHR() functions
'
' This function is useful, for example, when you are writing a MsgBox wizard.
' Tipically, such a wizard would let the user enter a string in a multiline
' textbox control, and would later have to convert it into a quoted string in
' order to produce the actual MsgBox code. Just putting quotes around the
' string doesn't work, because you have to account for embedded quotes and
' control characters.

Function StringToCode(ByVal Source As String) As String

    Dim Index As Integer
    Dim acode As Integer
    Dim result As String
    Dim openQuotes As Boolean
    
    For Index = 1 To Len(Source)
        acode = Asc(Mid(Source, Index, 1))
        If acode >= 32 Then
            If openQuotes = False Then
                result = result & """"
                openQuotes = True
            End If
            result = result & Chr(acode)
            ' double embedded quotes
            If acode = 34 Then result = result & Chr(acode)
        Else
            If openQuotes Then
                result = result & """ & "
                openQuotes = False
            End If
            Select Case acode
            Case 0
                result = result & "vbNullChar & "
            Case 13
                result = result & "vbCr & "
            Case 10
                result = result & "vbLf & "
            Case 9
                result = result & "vbTab & "
            Case Else
                result = result & "Chr$(" & CStr(acode) & ") & "
            End Select
        End If
    Next
    
    ' close open quotes
    If openQuotes Then
        result = result & """"
    ElseIf Right(result, 3) = " & " Then
        result = Left(result, Len(result) - 3)
    End If
    
    ' convert CR+LF to a single symbolic constant
    Do
        Index = InStr(result, "vbCr & vbLf")
        If Index = 0 Then Exit Do
        result = Left$(result, Index - 1) & "vbCrLf" & Mid$(result, Index + 11)
    Loop
    
    ' empty string is a special case
    If Len(result) = 0 Then result = """"""
    
    StringToCode = result
    
End Function
esta con todo y creditos los cuales se los agregue porque no estaba originalmente en el codigo.

nos vemos..
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila