*Formulario Pantalla Completa:
Me.WindowState = FormWindowState.Maximized
*Abrir canciones:
OpenFileDialog1.ShowDialog()
AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName
*Abrir páginas con un botón:
Try
System.Diagnostics.Process.Start("URL de la pagina")
Catch
'Code to handle the error.
End Try
*Códigos de login: (en este se deben usar un botón, 2 textbox y un formulario):
If TextBox1.Text = "Tu Usuario" And TextBox2.Text = "Tu Password" Then
Form2.Show()
Else
MsgBox("Incorrecta User/Password", MsgBoxStyle.Critical, "Titulo del mensaje")
End If
*Código para keygen: (en este caso se usa un textbox, un botón y un formulario):
TextBox1.Text = Int(Rnd() * 4)
Select Case TextBox1.Text
Case 0
TextBox1.Text = "XMLWDD-QQEWOLOFSF-Q10PP"
Case 1
TextBox1.Text = "XMLWDD-QQEWOLOFSF-Q10PP"
Case 2
TextBox1.Text = "XMLWDD-QQEWOLOFSF-Q10PP"
Case 3
TextBox1.Text = "XMLWDD-QQEWOLOFSF-Q10PP"
End Select
*Código para abrir archivos TXT: (este no estoy muy seguro que funcione):
Sub SaveTextBoxInFile(ByVal FileName As String, ByRef Text As TextBox)
On Error Resume Next
Close
Open FileName For Output As #1
If Err > 0 Then Exit Sub
Print #1, Text.Text
Close
End Sub
Sub GetFileToTextBox(ByVal FileName As String, ByRef Text As TextBox)
On Error Resume Next
Close
Open FileName For Input As #1
If Err > 0 Then Exit Sub
Text.Text = Input(LOF(1), 1)
Close
End Sub
Private Sub Command1_Click()
GetFileToTextBox "C:\Texto.txt", Text1
End Sub
Private Sub Command2_Click()
SaveTextBoxInFile "C:\Texto.txt", Text1
End Sub
*Reproducir un audio en un formulario:
My.Computer.Audio.Play("Directorio de la canción", AudioPlayMode.WaitToComplete)
*Códigos para crear un juego de Tic Tac Toe (estos códigos van separados por una raya larga, recuerden quitarla para que les funcione y asignar cada código con su respectivo lugar):
Form Code:
turn = 1
__________________________
Buttons Click X and O:
If turn = 1 Then
Button1.Text = "O"
Label2.Text = "X"
Else
Button1.Text = "X"
Label2.Text = "O"
End If
turn += 1
If turn > 2 Then
turn = 1
End If
Call win()
Button1.Enabled = False
____________________________________
Button Reset:
Button1.Text = ""
Button1.Enabled = True
Button2.Text = ""
Button2.Enabled = True
Button3.Text = ""
Button3.Enabled = True
Button4.Text = ""
Button4.Enabled = True
Button5.Text = ""
Button5.Enabled = True
Button6.Text = ""
Button6.Enabled = True
Button7.Text = ""
Button7.Enabled = True
Button8.Text = ""
Button8.Enabled = True
Button9.Text = ""
Button9.Enabled = True
_______________________________
Control Turn:
Dim turn As Integer
_________________________________
Other Command:
Private Sub win()
If Button1.Text = "X" And Button2.Text = "X" And Button3.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
ElseIf Button4.Text = "X" And Button5.Text = "X" And Button6.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
ElseIf Button7.Text = "X" And Button8.Text = "X" And Button9.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
ElseIf Button1.Text = "X" And Button4.Text = "X" And Button7.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
ElseIf Button2.Text = "X" And Button5.Text = "X" And Button8.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
ElseIf Button3.Text = "X" And Button6.Text = "X" And Button9.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
ElseIf Button1.Text = "X" And Button5.Text = "X" And Button9.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
ElseIf Button3.Text = "X" And Button5.Text = "X" And Button7.Text = "X" Then
MsgBox("Player X wins!")
Label6.Text += 1
Call disablebuttons()
''NOW FOR THE "O"!
'' MAke a big space here for fun
'so that we can see diff sides
ElseIf Button1.Text = "O" And Button2.Text = "O" And Button3.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
ElseIf Button4.Text = "O" And Button5.Text = "O" And Button6.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
ElseIf Button7.Text = "O" And Button8.Text = "O" And Button9.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
ElseIf Button1.Text = "O" And Button4.Text = "O" And Button7.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
ElseIf Button2.Text = "O" And Button5.Text = "O" And Button8.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
ElseIf Button3.Text = "O" And Button6.Text = "O" And Button9.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
ElseIf Button1.Text = "O" And Button5.Text = "O" And Button9.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
ElseIf Button3.Text = "O" And Button5.Text = "O" And Button7.Text = "O" Then
MsgBox("Player O wins!")
Label7.Text += 1
Call disablebuttons()
End If
_________________________________________________________________________________
Button Disable Other:
Private Sub disablebuttons()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Button8.Enabled = False
Button9.Enabled = False
*Códigos para crear un envío de mensajes a correos Gmail (estos códigos están separados por una larga raya, recuerda quitarlas y ponerlas en sus respectivos lugares, ahí dice donde va cada uno para no confundir):
Control Code:
Imports System.Net.Mail
_______________________________
Button Iniciar Sesion:
If ComboBox1.Text = "" Then
MsgBox("No Se Pudo Conectar Con El Servidor, Compruebe Su Correo", , "Mensaje:")
Else
If TextBox1.Text = "" Then
MsgBox("No Se Pudo Conectar Con El Servidor, Compruebe Su Contraseña", , "Mensaje:")
Else
MsgBox("Servidor: Gmail Mexico City: Conectado", , "Atencion!:")
sender.Show()
Me.Hide()
Me.Visible = False
Form2.Show()
End If
End If
________________________________________________________________________
Button Enviar:
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient
SmtpServer.Credentials = New Net.NetworkCredential(Form1.ComboBox1.Text, Form1.TextBox1.Text)
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail.To.Add(TextBox1.Text)
mail.From = New MailAddress(Form1.ComboBox1.Text)
mail.Subject = TextBox2.Text
mail.Body = TextBox3.Text
Try
SmtpServer.Send(mail)
MsgBox("Youre E-Mail Was Send", MsgBoxStyle.Information, "E-Mail Send")
Me.Close()
Form2.Show()
Catch ex As Exception
MsgBox("An Error Has Occured... Mail Did Not Send", MsgBoxStyle.Exclamation, "Error Please Retry")
MsgBox("Trying To Send Mail Agin", MsgBoxStyle.Exclamation, "Trying Agin")
End Try
viernes, 14 de junio de 2013
CODIGOS EN VISUAL BASIC
23:22
No comments
Suscribirse a:
Enviar comentarios (Atom)
0 comentarios:
Publicar un comentario