Solved

Simple Ping in VB 2..3 - Imports System.Net.NetworkInformation?????

Posted on 2006-11-11
8
868 Views
Last Modified: 2012-08-14
Hello All,

I'm a "somewhat decent" VB6 programmer making his first steps into VB 2003.  I'm just trying to duplicate some of my VB6 projects.  

One of them is a simple ping program.  On this site, I've seen a few references to doing this.  All of them mention that I need to "Import" System.Net.NetworkInformation.  However, when I look in PROJECT-Add Reference, I don't see that .Net or .Com object.  

The code example on this site is great...I just need to know how/where I can get this reference into my project.  

Chris, Baltimore.
0
Comment
Question by:clebo99
8 Comments
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17922730
Using "Import" doesn't necessarily require the Project > Add Reference procedure.

Just add to the top of your code:

Import System.Net.NetworkInformation



All it does is say "If I refer to something like System.Net.NetwokInformation.SomeClass I don't want to have to write the System.Net.NetworkInformation part every single time, so if you can't figure out what I'm talking about try it with a System.Net.NetworkInformation prefix on it."

If you don't mind the typing, even that's unnecessary.
0
 

Author Comment

by:clebo99
ID: 17922878
Thanks for the quick info....a snipit of the code I'm trying:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Imports (system)

        Import(System.Net.NetworkInformation)


        Dim testPing As New Ping
        Dim testResult As PingReply
        Dim testAddress As String = "www.yahoo.com"

        testResult = testPing.Send(testAddress)
        MsgBox(testResult.Address)
        MsgBox(testResult.Buffer)
        MsgBox(testResult.RoundtripTime)
        MsgBox(testResult.Status)
    End Sub
End Class

The problem is that I get the squiggly lines under "ping" and "pingreply" like it doesn't know what they are.   Even when I type in the system.net.networkinformation, it doesn't bring up networkinformation as a possible setting, just networkaccess and a list of others.

I think I'm just missing the reference/component, but I cannot find it....
0
 

Author Comment

by:clebo99
ID: 17922885
Specific errors"

Type "Ping" not defined.
Type "PingReply" not defined.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17922922
There's no need to add any special references, however you do need to be using version 2.0 of the .NET framework.  If you're in VS 2003 I expect you're using 1.1 (where there is no mechanism to ping anything).  Version 2.0 came out with Visual Studio 2005.  Come to think of it, I don't think 2.0 is compatible with VS 2003.


Looking at that snippet of code, incidentally, the Import belongs waaaaay at the top of the file, before any other lines of code.  It's not something done on a per-method basis.  There are also no parentheses; it's just:

Imports System.Net.NetworkInformation
0
 

Author Comment

by:clebo99
ID: 17923220
That makes sense...I am using 1.1......I'll see if 2.0 is compatible with 2003.  

Thanks!!!

Chris
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 17924822
Going to Project > Add Reference procedure. Is that the same as right clicking on the project in the explorer window and clicking on add reference ?

Just im thinking in terms of Project --> Add reference in terms of using the menu at the top as apposed to right clicking on the project in the explorer window on the right ( its generally on the right hand side )
0
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17924994
Yes, any way you add a reference to the project it has the same result.  In general anything you do from the Project menu is the same as what you'd do by right-clicking on the project.

I admit Microsoft has some strange UI ideas sometimes, but having identical features in two different menus behave differently is a bit out there even for them.  (-:
0
 
LVL 7

Accepted Solution

by:
yotamsher earned 500 total points
ID: 17926035
if you need Ping for DotNet 1.1, maybe this will help

http://www.codeproject.com/dotnet/CSharpPing.asp

Yotam
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# DataGridView_RowsAdded event not firing 1 74
iSeries email authority 6 56
Help Required 2 30
Query group by data in SQL Server - cursor? 3 30
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question