Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please let me find the bug(s) in a function 2

Status
Not open for further replies.

helpeachother

Programmer
Joined
Jun 1, 2005
Messages
13
Location
CA
Hello, everyone:

I am a new member of this group and need your help to dibug my code. I wrote a function named "getMemoryData" and it gives me an error message saying that the arguments are not specified,but I did. Will you help me to see the error(s) that I cannot see? Thanks.

The part of the code I am calling the function:
----------

'build url of memory usage frame page
url = txtePerf.Text + CType(hCustomers.Item(customer), String) + _
mtx + "_MTX/mtx_memory/tables/mtx_memory.1.php"


'grab the data off the web server
block = getWebPage(url)
Dim searchDate As String
searchDate = Format(linkDate, "yyyyMMdd")


memoryData = getMemoryData()

======================================
Here is the function:



Function getMemoryData(ByVal block As String, ByVal searchDate As String) As String()

Dim matches, num As System.Text.RegularExpressions.MatchCollection
Dim regExp As Regex

Dim temp, mData(3) As String
Dim tempDate As Date
Dim cnt As Integer

cnt = 0

mData(0) = "" : mData(1) = "" : mData(2) = "" : mData(3) = ""



For Each m As Match In matches 'process matches
temp = m.Value
If searchDate.ToString = Microsoft.VisualBasic.Left(temp, 8) Then


regExp = New Regex("<td[^>]*>(\d\d\d\d)(\d\d)(\d\d) \d\d:\d\d:\d\d</td>" + _
"\s*<td[^>]+?>(\d+)</td>\s*<td[^>]+?>(\d+)</td>\s*<td[^>]+?>(\d+)</td>" + _
"\s*<td[^>]+?>(\d+)</td>\s*<td[^>]+?>(\d+)</td>\s*<td[^>]+?>(\d+)</td>" + _
"\s*<td[^>]+?>(\d+)</td>\s*<td[^>]+?>(\d+)</td>\s*<td[^>]+?>(\d+)</td>")
matches = regExp.Matches(block)

End If

Next

'Only do this if there was a result from MTX Memory page
If matches.Count > 0 Then
Dim memoryData(3) As String



'process data if the date matches.
For Each m As Match In matches
memoryData(0) = m.Groups(4).ToString 'DS Used (KB)
memoryData(1) = m.Groups(7).ToString 'PS Used (KB)
memoryData(2) = m.Groups(12).ToString 'Provisioned Memory (KB)
memoryData(3) = m.Groups(11).ToString 'Physical Spare (KB)
cnt += 1
mData = memoryData

Next

End If


Return (mData)

End Function

=================================================
Thanks for your help!

KHWright
 
try this

Code:
memoryData = getMemoryData(block,searchdate)


Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
You may also want to look at this line:
Code:
if searchDate.ToString = Microsoft.VisualBasic.Left(temp, 8) then

date.tostring will change based on your culture settings I beleive. In many cases, it won't be 8 characters, and can change from machine to machine. If you want to compare the string value, format it, if you want to compare the date value, convert the value in temp to a date.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
date.tostring will change based on your culture settings I beleive.

Very tru and a very big nightmare and this side of the ocean.
Try this instead.

Code:
searchDate.ToString("mm/dd/yyyy")

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Your post subject sounds like my morning prayer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top