|
-
Mar 20th, 2006, 10:12 AM
#1
Thread Starter
Hyperactive Member
Old string functions [Resolved]
Hi,
have just been looking at a bit of code submitted by Gigemboy to redivert the results from a cmd prompt. I want to use this to check to see if a server is running by pinging it and seeing how many packets were returned.
Anyway am waffaling a bit, my main questions is how to make this more .net like, eg not using mid and instr.
Had a quick look at the string class but can't see any equivalants (sure I'm just missing them though)
VB Code:
Private Function succesfulping(ByVal cmdp As String) As Boolean
Dim recp As Integer
Dim pacr As Integer
recp = InStr(cmdp, "Received") + 11
Try
pacr = CInt(Mid(cmdp, recp, 1))
Catch
pacr = 0
End Try
Select Case pacr
Case 0
succesfulping = False
Case 1
succesfulping = False
Case 2
succesfulping = False
Case 4
succesfulping = True
Case Else
succesfulping = False
End Select
End Function
Last edited by Oliver1; Mar 20th, 2006 at 11:44 AM.
Reason: Resolved
-
Mar 20th, 2006, 10:16 AM
#2
-
Mar 20th, 2006, 10:31 AM
#3
Thread Starter
Hyperactive Member
Re: Old string functions
Thanks just need an instr replacement now.
-
Mar 20th, 2006, 10:32 AM
#4
Re: Old string functions
Whoopsies, I missed that 
InStr equates to .IndexOf().
-
Mar 20th, 2006, 08:31 PM
#5
Re: Old string functions [Resolved]
Our Clear VB source code formatter produces:
...
recp = (cmdp.IndexOf("Received", 0) + 1) + 11
Try
pacr = CInt(cmdp.Substring(recp - 1, 1))
Catch
pacr = 0
End Try
...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|