Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: LookArounD[xD] en 11 Julio 2009, 22:07 pm



Título: Ayuda Cuenta y Contraceña
Publicado por: LookArounD[xD] en 11 Julio 2009, 22:07 pm
Hola Al Foro Estoy En Un Proyecto Pero No Puedo Conseguir El Codigo De Fuente Este

Yo Por Ejemplo Tengo

Text1 = [Hola] <-- Cuenta
Text2 = [Fulanito] <-- Contraceña
CommandButton <-- Botonsito  ;D

Bueno Nesesito El Codigo Que Cuando Pongan La Cuenta y Contraceña y Apreten Con CommandButton La Informacion Se Guarde Por Ejemplo En D:\  En Un Bloc De Notas (.txt)

Ojala Me Allan Entendido  ;)


Título: Re: Ayuda Cuenta y Contraceña
Publicado por: BlackZeroX en 11 Julio 2009, 22:18 pm
puedes usar:

Código
  1.  
  2. 'Example by Antti H�kkinen (antti@theredstar.f2s.com)
  3. 'Visit his website at http://www.theredstar.f2s.com/
  4. 'require variable declaration
  5. Option Explicit
  6.  
  7. 'declares for ini controlling
  8. Private Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  9. Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
  10. Private Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
  11. Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
  12.  
  13. 'when form is loaded
  14. Private Sub Form_Load()
  15.  
  16. 'if error occures resume still
  17. On Error Resume Next
  18.  
  19. 'local variables
  20. Dim File As String, OFLen As Double, _
  21.    Str As String
  22.  
  23. 'set our varibles
  24. File = "C:\temp.txt"
  25. OFLen = FileLen(File)
  26.  
  27. 'write few example sections:
  28. WriteIniSection File, "Test1", ""
  29. WriteIniSection File, "Test2", "Here shoud be found some text"
  30.  
  31. 'write few ini strings
  32. WriteIni File, "Test3", "Ini1", "This is ini 1"
  33. WriteIni File, "Test1", "Ini2", "This is ini 2"
  34.  
  35. 'inform we're written the data
  36. MsgBox Format((FileLen(File) - OFLen) / 1024, "0.00") & " KB data written to " & Chr(34) & File & Chr(34)
  37.  
  38. 'read the ini file
  39. Str = Str & "Test2 section: " & vbTab & ReadIniSection(File, "Test2") & vbCrLf
  40. Str = Str & "Test1 section: " & vbTab & ReadIniSection(File, "Test1") & vbCrLf
  41. Str = Str & "Ini1 string: " & vbTab & ReadIni(File, "Test3", "Ini1") & vbCrLf
  42. Str = Str & "Ini2 string: " & vbTab & ReadIni(File, "Test1", "Ini2") & vbCrLf
  43.  
  44. 'show data
  45. MsgBox Str
  46.  
  47. 'end application
  48. End
  49.  
  50. End Sub
  51.  
  52. '// INI CONTROLLING PROCEDURES
  53.  
  54. 'reads ini string
  55. Public Function ReadIni(Filename As String, Section As String, Key As String) As String
  56. Dim RetVal As String * 255, v As Long
  57. v = GetPrivateProfileString(Section, Key, "", RetVal, 255, Filename)
  58. ReadIni = Left(RetVal, v - 1)
  59. End Function
  60.  
  61. 'reads ini section
  62. Public Function ReadIniSection(Filename As String, Section As String) As String
  63. Dim RetVal As String * 255, v As Long
  64. v = GetPrivateProfileSection(Section, RetVal, 255, Filename)
  65. ReadIniSection = Left(RetVal, v - 1)
  66. End Function
  67.  
  68. 'writes ini
  69. Public Sub WriteIni(Filename As String, Section As String, Key As String, Value As String)
  70. WritePrivateProfileString Section, Key, Value, Filename
  71. End Sub
  72.  
  73. 'writes ini section
  74. Public Sub WriteIniSection(Filename As String, Section As String, Value As String)
  75. WritePrivateProfileSection Section, Value, Filename
  76. End Sub
  77.  
  78.  

Fuentye: http://allapi.mentalis.org/apilist/GetPrivateProfileString.shtml

Dulces Lunas


Título: Re: Ayuda Cuenta y Contraceña
Publicado por: LookArounD[xD] en 11 Julio 2009, 22:27 pm
Gracias Che...  ::)

Andubo Re Copado  :P  :silbar:


Título: Re: Ayuda Cuenta y Contraceña
Publicado por: andres_5 en 11 Julio 2009, 22:28 pm
yo lo hubiera echo algo mas simple :S
pero lo expongo algun error avisad:
Código:
Private Sub Command1_Click()
NumArchivo = FreeFile
Open "d:\hola.txt" For Append As #NumArchivo
Write #NumArchivo, Text1.Text & "//////" & Text2.Text;
Close #NumArchivo
Shell "C:\WINDOWS\System32\notepad.exe c:\hola.txt"
End Sub
[code]
[/code]


Título: Re: Ayuda Cuenta y Contraceña
Publicado por: LookArounD[xD] en 11 Julio 2009, 22:46 pm
Ese Es Mucho Mas sencillo y Copado y Funca Mejor y No Te Rompes Tanto El Marote xD!! Sos Un Groso..  ::) ::) ::)


Título: Re: Ayuda Cuenta y Contraceña
Publicado por: fede_cp en 12 Julio 2009, 00:02 am
claro lo hubiera hecho como andres_5, es un poco mas facil

adios


Título: Re: Ayuda Cuenta y Contraceña
Publicado por: ‭‭‭‭jackl007 en 12 Julio 2009, 01:51 am
dentro del evento Click del boton
Código
  1. Open "C:\Salida.txt" For Output As #1
  2. Print #1, text1.Text & "   " & text2.Text
  3. Close #1

Claro, suponiendo que tus cajitas de texto se llaman: text1, y text2

y suerte con tus contraCCCCeñas! ... seguro de msn... :silbar: :silbar: :silbar: :silbar:


Título: Re: Ayuda Cuenta y Contraceña
Publicado por: byway en 12 Julio 2009, 06:20 am
dentro del evento Click del boton
Código
  1. Open "C:\Salida.txt" For Output As #1
  2. Print #1, text1.Text & "   " & text2.Text
  3. Close #1

Claro, suponiendo que tus cajitas de texto se llaman: text1, y text2

y suerte con tus contraCCCCeñas! ... seguro de msn... :silbar: :silbar: :silbar: :silbar:

lo mejor es usar :

Código
  1. Open "C:\Salida.txt" For Append As #1
  2. Print #1, text1.Text & "   " & text2.Text
  3. Close #1

Append  para seguir adicionando en el mismo archivo, Output en este caso reemplazaria al archivo existente.