Currently, I have an application which will open webpages and such by the means of clicking a button. All of that works fine, but what I am really wanting to do is send out a tiny ping every once in a while so people will know if the servers are online or offline before they try to join. I would simply want it to say "Online" or "Offline" below it. How would I constantly check if a server is up?
Here is the code I have so far:
Public Class MainApp
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Process.Start ("steam://connect/216.52.148.114:2302") ' -Not WORKING
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Process.Start ("WEBSITEURL") ' -WORKS
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Process.Start ("TEAMSPEAK IP") ' -WORKS
End Sub
End Class
It all works fine except connecting to the Arma 3 server through Steam. It does this:
Related
I'm trying to figure out how to disable my form(Form1.vb) without hiding it then enabling it after I'm done with the other form(Form2.vb).
I've searched on youtube but it says C#. I've tried it but somehow it was indicated as an error in VS 2015. I tried messing around with the syntax because I really can't figure it out. The syntax that I have tried is "LandingForm.ActiveForm.Owner.Enabled = True".
Indicated below are the codes of my system. The first one is form1.vb/LandingForm.vb and the second one is form2.vb/AcctSettings.vb.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Enabled = False
AcctSettings.Show()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
LandingForm.ActiveForm.Owner.Enabled = True
Me.Hide()
End Sub
Am I missing something? Can somebody help?
On your form1 just have a simple line like
Form2.Show()
wherever/however you wish to open the other form (button etc.)
then in the code for that form2 in the formload handeler have
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Form1.Enabled = False
End Sub
This will keep form1 open but basically grey it out.
Then have a simple button click like so to have access to form 1.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form1.Enabled = True
End Sub
And you are done! And if you wish just add another button or a IF statement to the button2 sub and say form1.enabled = false if you want to be able to enable/disable etc.
To enable/disable your userform :
To disable your userform you will need yo enable it before :
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Form1.Enabled = True
Form1.Enabled = False
End Sub
To disable it will be easier you just got to set your userform.enabled as False
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Form2.Enabled = True
End Sub
If you want to close your userform useroform.Unload might be the solution.
In your code it would be like this :
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Enabled = False
AcctSettings.Show()
form1.Unload
End Sub
and
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
LandingForm.ActiveForm.Owner.Enabled = True
Me.Hide()
form2.Unload
End Sub
an other option is to Hide your user form : it will just hide the userform and will not release the objects and variables from the memory. Where as Unload method will release the objects and variables from the memory.
UserForm1.Hide
To conclude : Hide method will be used when we want to hide the form temorarly and to show after sometime to the user. Where as unload will be used when it completes the task.
Note that this is YourUserForm_Name.Unload
I'm trying to download a .pdf file using web browser
The thing is the .pdf file does not have a direct link because the website creates the pdf file according to the user input and then replies with the pdf
Code included which fills all the data and clicks next when needed
After I fill the data with my code and click on download a new page on internet explorer opens and nothing happens instead of downloading the file
How can I download the pdf file through my program
Here is my code
Imports System.Net
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("https://www.misim.gov.il/gmIshurim/firstPage.aspx")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("rbMeshalem").InvokeMember("click")
WebBrowser1.Document.GetElementById("btnNext").InvokeMember("click")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
WebBrowser1.Document.GetElementById("txtMisTikMeshalem").SetAttribute("value", "510001001")
WebBrowser1.Document.GetElementById("txtTik1").SetAttribute("value", "510000367")
WebBrowser1.Document.GetElementById("btnNext").InvokeMember("click")
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
WebBrowser1.Document.GetElementById("cbSelectAll").InvokeMember("click")
WebBrowser1.Document.GetElementById("btnPrintIshur").InvokeMember("click")
End Sub
End Class
I am trying to incorporate VLC into my VB program. I have included the COM tool VLCActiveXPlugin_V2. In the ‘openfiledialog1’ properties the ‘InitialDirectory’ is set to ‘E:\Movies\’,which is where my .mp4 movies are stored. When I run the program and press btnLoad the openfiledialog1 opens E:\Movies but it said ‘No items match your Search’! The code is adapted from a .net tutorial and works fine for him. I am ‘ASSUMING’ it was written with an older version of VB and/or .NET.
Anybody have any ideas?
This is just a test trying to get the playback to work, the end product will be that a user can create a DataGridView listing of the available movies, pick one of the movies and ‘hopefully’ the program will play that movie.
Code:
Public Class Form1
Private Sub btnLoad_Click(sender As Object, e As EventArgs) Handles
btnLoad.Click
OpenFileDialog1.Filter = " (*.mp4) | .mp4 "
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
AxVLCPlugin21.playlist.add(OpenFileDialog1.FileName)
End If
End Sub
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles
btnStart.Click
AxVLCPlugin21.playlist.play()
End Sub
Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles
btnStop.Click
AxVLCPlugin21.playlist.stop()
End Sub
Private Sub btnPause_Click(sender As Object, e As EventArgs) Handles
btnPause.Click
AxVLCPlugin21.playlist.togglePause()
End Sub
End Class
Just noticed in one of my programs that the form event Shown only runs the code when the form is first displayed. Every other time after that it does not run the code. Is there a form event that does what shown does, but every time it is displayed instead of just the first? Or is there a way to get around it? This is the exact same for the Load event too.
Thanks heaps, appreciate any response.
I just tested with this in Form1:
Private f2 As New Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
f2.Show()
End Sub
and this in Form2:
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MessageBox.Show("Form2_Load")
End Sub
Private Sub Form2_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged
If Visible Then
MessageBox.Show("Form2_VisibleChanged")
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Hide()
End Sub
and it worked exactly as expected. Every time I clicked Button1 in Form1, Form2 was displayed. The first time I saw messages for "Form2_Load"and "Form2_VisibleChanged" and on subsequent occasions on for "Form2_VisibleChanged".
IN CODE: At 1 browser clicks a button and takes a time to load. AT 2 i get source code of page in RichTextBox1. but as page take time to load code 2 starts before completion of 1 because of that i am unable to get the web page source at desired state? what do i do ? i want to get web page source when web browser completely loads after the execution of code 1.
i have tried
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.WebBrowser1.Navigate("some website")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Document.GetElementById("notification_address").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.Forms(0).InvokeMember("submit") (-----1-----)
RichTextBox1.Text = WebBrowser1.DocumentText (-----2-----)
End Sub
You can use the DocumentCompleted event.
https://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documentcompleted(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
Private Sub DocumentCompleted(ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
' this is where your code goes RichTextBox1.Text = WebBrowser1.DocumentText (-----2-----)
End Sub