Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => 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 (vb) [Seleccionar]


'Example by Antti H�kkinen (antti@theredstar.f2s.com)
'Visit his website at http://www.theredstar.f2s.com/
'require variable declaration
Option Explicit

'declares for ini controlling
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
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
Private Declare Function WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
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

'when form is loaded
Private Sub Form_Load()

'if error occures resume still
On Error Resume Next

'local variables
Dim File As String, OFLen As Double, _
   Str As String

'set our varibles
File = "C:\temp.txt"
OFLen = FileLen(File)

'write few example sections:
WriteIniSection File, "Test1", ""
WriteIniSection File, "Test2", "Here shoud be found some text"

'write few ini strings
WriteIni File, "Test3", "Ini1", "This is ini 1"
WriteIni File, "Test1", "Ini2", "This is ini 2"

'inform we're written the data
MsgBox Format((FileLen(File) - OFLen) / 1024, "0.00") & " KB data written to " & Chr(34) & File & Chr(34)

'read the ini file
Str = Str & "Test2 section: " & vbTab & ReadIniSection(File, "Test2") & vbCrLf
Str = Str & "Test1 section: " & vbTab & ReadIniSection(File, "Test1") & vbCrLf
Str = Str & "Ini1 string: " & vbTab & ReadIni(File, "Test3", "Ini1") & vbCrLf
Str = Str & "Ini2 string: " & vbTab & ReadIni(File, "Test1", "Ini2") & vbCrLf

'show data
MsgBox Str

'end application
End

End Sub

'// INI CONTROLLING PROCEDURES

'reads ini string
Public Function ReadIni(Filename As String, Section As String, Key As String) As String
Dim RetVal As String * 255, v As Long
v = GetPrivateProfileString(Section, Key, "", RetVal, 255, Filename)
ReadIni = Left(RetVal, v - 1)
End Function

'reads ini section
Public Function ReadIniSection(Filename As String, Section As String) As String
Dim RetVal As String * 255, v As Long
v = GetPrivateProfileSection(Section, RetVal, 255, Filename)
ReadIniSection = Left(RetVal, v - 1)
End Function

'writes ini
Public Sub WriteIni(Filename As String, Section As String, Key As String, Value As String)
WritePrivateProfileString Section, Key, Value, Filename
End Sub

'writes ini section
Public Sub WriteIniSection(Filename As String, Section As String, Value As String)
WritePrivateProfileSection Section, Value, Filename
End Sub



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:

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 (vb) [Seleccionar]
Open "C:\Salida.txt" For Output As #1
Print #1, text1.Text & "   " & text2.Text
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
Cita de: jackl007 ツ en 12 Julio 2009, 01:51 AM
dentro del evento Click del boton
Código (vb) [Seleccionar]
Open "C:\Salida.txt" For Output As #1
Print #1, text1.Text & "   " & text2.Text
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 (vb) [Seleccionar]
Open "C:\Salida.txt" For Append As #1
Print #1, text1.Text & "   " & text2.Text
Close #1


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