elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Entrar al Canal Oficial Telegram de elhacker.net


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación Visual Basic / Re: [RETO] uCaseCorrect. Corrector de Mayusculas! en: 11 Mayo 2016, 17:51 pm
Este es mi código, espero que os guste. :P
Código
  1. Private Function uCaseCorrector(txt As String) As String
  2.    Dim Signos As String
  3.    Dim Espacios() As Integer
  4.    Dim a, b As Integer
  5.    Dim tmp As String
  6.    Dim tmp2 As String
  7.  
  8.    'Los signos a controlar, se puede incrementar
  9.    Signos = ".;:¿?¡!"
  10.  
  11.    'Sacamos los espacios
  12.    ReDim Espacios(1 To Len(txt))
  13.  
  14.    For a = 1 To Len(txt)
  15.        b = b + 1
  16.        If Mid(txt, a, 1) = " " Then
  17.            Espacios(b) = b
  18.            b = b - 1
  19.        Else
  20.            tmp = tmp + Mid(txt, a, 1)
  21.        End If
  22.    Next a
  23.  
  24.    b = 0
  25.  
  26.    'Corregimos el texto
  27.    For b = 1 To Len(Signos)
  28.        For a = 1 To Len(tmp)
  29.            If Mid(tmp, a, 1) = Mid(Signos, b, 1) And a + 1 < Len(tmp) Then
  30.                Mid(tmp, a + 1, 1) = UCase(Mid(tmp, a + 1, 1))
  31.            End If
  32.        Next a
  33.    Next b
  34.  
  35.    'Colocamos los espacios
  36.    For a = 1 To Len(txt)
  37.        If Espacios(a) <> 0 Then
  38.            tmp2 = tmp2 + " " + Mid(tmp, a, 1)
  39.        Else
  40.            tmp2 = tmp2 + Mid(tmp, a, 1)
  41.        End If
  42.    Next a
  43.  
  44.    'La Solucion
  45.    uCaseCorrector = tmp2
  46. End Function
  47.  

Saludos
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines