Ping a server on a VPN network.

Hello All,

I've only just started to develope some code in VB.net and i have very little experience in it and some of the "instructional" web pages are very confusing to my dyslexic mind.

The scenario is as follows: -

I am connected to a server via VPN, but the connection speed to the server is kind of erratic. The CAD software I use in my day job, is quite processor hungry/dependent and sometimes the CAD software will stop working as it processes work/commands. Sometimes the issue is not the CAD software, but the latency of the VPN connection (this is not at my end, but the server connection). When the CAD stops working, I start a command prompt window and ping the server and get something like the following.

Ping.jpg

I would like to do something similar in vb.net.

I have a user form with a button on it to ping the cad server and this works and I can get a single result.

This uses the following code (which I have borrowed from somewhere):

    Private Sub OnePingCadSvr_Click(sender As Object, e As EventArgs) Handles OnePingCadSvr.Click

        Dim host As String = "0.0.0.0"
        Dim pingreq As Ping = New Ping()
        Dim rep As PingReply = pingreq.Send(host)
        Dim SingleRoundtripTime As Long

        Console.WriteLine("Pinging {0} [{1}]", host, rep.Address.ToString())
        Console.WriteLine("Reply From {0} : time={1} TTL={2}", rep.Address.ToString(), rep.RoundtripTime, rep.Options.Ttl)
        PingHost.Text = "Reply From: " & rep.Address.ToString()
        PingHost.Refresh()
        PingRoundTrip.Text = "Round Trip Time: " & rep.RoundtripTime & "ms" ' & rep.Options.Ttl
        PingRoundTrip.Refresh()
        System.Threading.Thread.Sleep(1500)

    End Sub

If I try to run this 4 times in a FOR loop, the round trip time is exactly the same time for each iteration of the loop i.e. If I get 27ms for the first iteration, it will be the same value for the remaining iterations, whereas manually repeating a single ping, 4 times, I get slightly different speeds (as I would expect) and more inline with the cmd ping.

It almost feels like I need to reset something before each iteration of the FOR loop starts, but I dont have a clue.

I have tried using google and I've gone through lots of different web sites and not come up with a solution, this is mainly because I don't really understand the syntax

Can anyone help?

I also realise that my code is probably not the best, but Im trying to learn as I go.

Thanks in advance, Steve

How to open an Excel Document in VB.NET

Hello clever people,

Completely new to VB.NET (only installed Visual Studio 2019 in the past couple of days).

To start all I want to do is open Excel (office 365) from a button on a userform. The location of the file is on a network, lets say: -

\file-svr01\Rozel\Design\Parts\PNG.xlsx
OR
R:\Design\Parts\PNG.xlsx

I don't need to read in any information from the spread sheet, just open it so thgat i can edit it.

Please bear in mind I am completely new to VB.NET, so if I have to initialise anything in the code before trying to open excel, it would be good if you can put this in any possible solutions.

I have tried using google, I've gone through lots of different web sites and tried lots of things and nothing works, but mainly because I don't really understand the syntax

Can anyone help?

Thanks.