Quantcast

Maximum PC

It is currently Thu Oct 30, 2014 11:15 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 19 posts ] 
Author Message
 Post subject: Visual Basic Help
PostPosted: Tue Nov 02, 2004 6:54 pm 
8086
8086

Joined: Wed Aug 25, 2004 8:30 pm
Posts: 50
Hey all,
I have been having some problems with visual basic and they are as follows:

1) I have been trying to find some way to ping a remote server, however i have been unsuccessful in my search

2) I figured that maybe i could run the ping.exe as a shell and read the output from that but, i do not know how to read output from a shell (In other words i would appreciate if someone could tell me how)

3) The people who i am mak,ing this program for are expecting it soon.

Basically what i am trying to do is make a program which minimizes to the task tray (another ordeal) and displays a green dot in the task tray if it can successfully ping a server specified by the user. If it can not reach that server, the dot turns red. However i hit my first problem when i ran into the above three points. Please answer back as this is important.

PS. There is a possibility that this can not be done.


Top
  Profile  
 
 Post subject: Re: Visual Basic Help
PostPosted: Tue Nov 02, 2004 8:39 pm 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
short4lif2 wrote:
Hey all,
I have been having some problems with visual basic and they are as follows:

1) I have been trying to find some way to ping a remote server, however i have been unsuccessful in my search

2) I figured that maybe i could run the ping.exe as a shell and read the output from that but, i do not know how to read output from a shell (In other words i would appreciate if someone could tell me how)

3) The people who i am mak,ing this program for are expecting it soon.

Basically what i am trying to do is make a program which minimizes to the task tray (another ordeal) and displays a green dot in the task tray if it can successfully ping a server specified by the user. If it can not reach that server, the dot turns red. However i hit my first problem when i ran into the above three points. Please answer back as this is important.

PS. There is a possibility that this can not be done.


What version of VB are referring too? VB6? VB.NET? Let us know, VB is a broad term, any details will aid us in helping you. :)


Top
  Profile  
 
 Post subject: I am using VB.NET
PostPosted: Wed Nov 03, 2004 4:03 pm 
8086
8086

Joined: Wed Aug 25, 2004 8:30 pm
Posts: 50
Yeah it's vb.net


Top
  Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 8:18 pm 
Team Member Top 100
Team Member Top 100

Joined: Fri Sep 17, 2004 5:35 pm
Posts: 1176
Does it have to be in VB.NET? I can give you a C++ solution.

EDIT:
Here's an idea:
call ping.exe with whatever you want, but then pipe the output to a file (i.e. "ping.exe www.maximumpc.com >log.txt"). Then read the log file in and parse it.


Top
  Profile  
 
 Post subject: Sorry! Not very helpful
PostPosted: Sat Nov 06, 2004 2:30 pm 
8086
8086

Joined: Wed Aug 25, 2004 8:30 pm
Posts: 50
I truly appreciate that you tried but i did not quite understand what you meant! If you could rephrase, or if anyone has any ideas, i would appreciate.


Top
  Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 2:33 pm 
Smithfield
Smithfield
User avatar

Joined: Sun Sep 05, 2004 9:01 am
Posts: 8091
You have some sort of book or manual right? Winsock should be able to do this pretty easy. Look up the winsock functions.


Top
  Profile  
 
 Post subject: Re: Sorry! Not very helpful
PostPosted: Sat Nov 06, 2004 3:21 pm 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24229
Location: Granite Heaven
short4lif2 wrote:
I truly appreciate that you tried but i did not quite understand what you meant! If you could rephrase, or if anyone has any ideas, i would appreciate.


What have you got so far? Anything? What do you need help with, exactly?

So far, it sounds like you are asking us to write the application for you ... which, given that most of us are either professionals or students (and some both) just isn't going to happen.

Well, the professionals might ... but we'd have to talk $ first.


Top
  Profile  
 
 Post subject: OK sorry about this
PostPosted: Sat Nov 06, 2004 8:22 pm 
8086
8086

Joined: Wed Aug 25, 2004 8:30 pm
Posts: 50
Sorry about this but the problem thinned out a lot. I started using the Visual Basic Express edition (which rules) and since it uses .NET 2.0 there is actually a ping object. so now, i managed to ping the server, however the only problem is that instead of telling me that it did not work (when it doesn't) it gives me an error. bassically what i did is told it to you use notifyicon1 if it worked and notifyicon2 if it failed. but instead of seeing notifyicon2 i see "you're code is messed BURN!"... although not exactly like that. I am in a hurry so i can't tell you exactly what the error said but it should not be there but thanks!


Top
  Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 8:30 pm 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24229
Location: Granite Heaven
This is why we use error handling routines.

You have to create an error trap that catches the error and, rather than interupt your program, it can send the appropriate message to your notifyicon2.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 07, 2004 3:57 am 
Team Member Top 100
Team Member Top 100

Joined: Fri Sep 17, 2004 5:35 pm
Posts: 1176
It seems you have your problem worked out (at least to the extent that I can help), but if you still want to know what I meant, then read on. If not, then skip it :)


Try this out:
Start > Run > "cmd.exe". Now, get to your desktop. If you're using Windows XP, then type, "cd Desktop". Now, ping a server. Let's use www.maximumpc.com. The command would look like this: "ping.exe www.maximumpc.com". It should give you some data. Now, take advantage of Windows's built-in pipes. A simple stdout pipe would use the '>' sign. To put ping.exe's output in a file called "pinglog.txt", the command would be this: "ping.exe www.maximumpc.com > pinglog.txt". Try it out. After less than a second, maybe a bit more, it will give you back the command prompt. Now look at your desktop. Do you see a file called "pinglog.txt"? It's there. Now, open it up. Here's what it said for me:
Quote:

Pinging www.maximumpc.com [64.191.196.129] with 32 bytes of data:



Reply from 64.191.196.129: bytes=32 time=20ms TTL=246

Reply from 64.191.196.129: bytes=32 time=19ms TTL=246

Reply from 64.191.196.129: bytes=32 time=18ms TTL=246

Reply from 64.191.196.129: bytes=32 time=19ms TTL=246



Ping statistics for 64.191.196.129:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 18ms, Maximum = 20ms, Average = 19ms




As you can see, this would be an effective way to use ping.exe and not have to do any work. What I'd suggest is just spitting the file to C:\, then deleting it after you're done with it (and ping.exe is, too).


The only drawback is that you must create a file. Though the file can be deleted, this isn't the ideal solution.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 07, 2004 7:48 am 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24229
Location: Granite Heaven
I'm not familiar with MS scripting (it has been a loooooong time), but can't you pipe the output into something other than a file? It seems silly to require hard drive access for so little data ... piping that output into a buffer and parsing it for the info you need as necessary (and flushing the buffer regularly!) seems a more efficient use of resources, IMO.


Top
  Profile  
 
 Post subject:
PostPosted: Sun Nov 07, 2004 12:35 pm 
Team Member Top 100
Team Member Top 100

Joined: Fri Sep 17, 2004 5:35 pm
Posts: 1176
Sure. You can pipe one program's stdout to another's stdin. But that would mean giving up input. Also, can VB create console applications?

Alternatively, you can look in the MSDN to see if you can find a way to read console output ;) (There is at least one way :))


Top
  Profile  
 
 Post subject: thanks a lot
PostPosted: Sun Nov 07, 2004 1:39 pm 
8086
8086

Joined: Wed Aug 25, 2004 8:30 pm
Posts: 50
Wow i did not think that i would get so many replies and i really appreciate. i like the ideas a lot!


Top
  Profile  
 
 Post subject: i found it
PostPosted: Thu Nov 11, 2004 8:21 am 
8086
8086

Joined: Wed Aug 25, 2004 8:30 pm
Posts: 50
OK guys i got it to work so if you want the code, here it is
Code:
On Error GoTo ErrorHandler
        If My.Computer.Network.Ping(TextBox1.Text) Then
            NotifyIcon2.Visible = True
            NotifyIcon3.Visible = False
        End If
        Timer1.Enabled = True
        If NotifyIcon2.Visible = True Or NotifyIcon3.Visible = True Then
            NotifyIcon1.Visible = False
        End If
        Me.Hide()
        Exit Sub
ErrorHandler:
        Me.Hide()
        NotifyIcon1.Visible = False
        NotifyIcon3.Visible = True
        NotifyIcon2.Visible = False


Top
  Profile  
 
 Post subject: Re: i found it
PostPosted: Thu Nov 11, 2004 8:28 am 
Professional Dork
Professional Dork
User avatar

Joined: Tue May 25, 2004 12:44 pm
Posts: 1246
Location: Cornhole County
short4lif2 wrote:
OK guys i got it to work so if you want the code, here it is
Code:
On Error GoTo ErrorHandler
        If My.Computer.Network.Ping(TextBox1.Text) Then
            NotifyIcon2.Visible = True
            NotifyIcon3.Visible = False
        End If
        Timer1.Enabled = True
        If NotifyIcon2.Visible = True Or NotifyIcon3.Visible = True Then
            NotifyIcon1.Visible = False
        End If
        Me.Hide()
        Exit Sub
ErrorHandler:
        Me.Hide()
        NotifyIcon1.Visible = False
        NotifyIcon3.Visible = True
        NotifyIcon2.Visible = False


See, this is the thing with VB.NET. If you're used to version 6 or earlier, you think in the API mindset, and .NET just has all these cool-ass functions built right in.

It can be both infuriating and beautiful.


Top
  Profile  
 
 Post subject: what?
PostPosted: Thu Nov 11, 2004 5:20 pm 
8086
8086

Joined: Wed Aug 25, 2004 8:30 pm
Posts: 50
see, i believe that the whole "the hardest way to do it is the most hardcore and cool way to do it" is such a senseless mindset. For that exact reason i am a VB.NET user. All the assembly and C coders are more into the 1 hour of work rather than 5 minutes of work idea. i do not understand how built in features are infuriating.


Top
  Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 5:44 pm 
Java Junkie
Java Junkie
User avatar

Joined: Mon Jun 14, 2004 10:23 am
Posts: 24229
Location: Granite Heaven
... not everyone runs windows, not all windows users have the NET framework installed, AND many programs require far more than .NET provides.

Having said that ... nice work. :D


Top
  Profile  
 
 Post subject: Re: what?
PostPosted: Thu Nov 11, 2004 7:14 pm 
Bitchin' Fast 3D Z8000
Bitchin' Fast 3D Z8000
User avatar

Joined: Mon Jun 14, 2004 4:04 pm
Posts: 985
Location: Earth
short4lif2 wrote:
see, i believe that the whole "the hardest way to do it is the most hardcore and cool way to do it" is such a senseless mindset. For that exact reason i am a VB.NET user. All the assembly and C coders are more into the 1 hour of work rather than 5 minutes of work idea. i do not understand how built in features are infuriating.


That's because those Assembly and C coders are usually trying to maximize performance by writing the code themselves. If you write Operating Systems for a living, chances are it will be in C.
That, and no singular language is the end-all-be-all language. Different tools for different jobs, much like you don't use a monkey wrench to screw in a light bulb.

Although VB.NET has its merits, some people actually like the hardcore way of writing things. Sure, it's not necessarily the best way, but it's a challenge to them and some live for the challenge.


Top
  Profile  
 
 Post subject: Re: what?
PostPosted: Fri Nov 12, 2004 3:46 am 
Professional Dork
Professional Dork
User avatar

Joined: Tue May 25, 2004 12:44 pm
Posts: 1246
Location: Cornhole County
short4lif2 wrote:
see, i believe that the whole "the hardest way to do it is the most hardcore and cool way to do it" is such a senseless mindset. For that exact reason i am a VB.NET user. All the assembly and C coders are more into the 1 hour of work rather than 5 minutes of work idea. i do not understand how built in features are infuriating.


While I agree with your "the hardest way to do it is the most hardcore and cool way to do it" point, I should point out that understanding the underlying logic and processes behind what you're doing can be a real benefit when you hit something that .NET doesn't cover.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

© 2014 Future US, Inc. All rights reserved.