-
August 14th, 2012, 06:12 AM
#1
arrays
hi
i have to get this arraydone and im stuck any help would be great
the first part of code reads the info from a table and writes it to a text file
Code:
Private Function MidRange()
On Error GoTo MidRange_Error
Cmd$ = "SELECT MOODYSIRB,FITCHIRB ,SPIRB " + CRLF$
Cmd$ = Cmd$ + " FROM ACRT" + CRLF$
Cmd$ = Cmd$ + " SAVE TO " + OPXCOM$ + "\MidRating.TXT DELIMITED;"
'************** End of Custom Code Section - Select ************
'*** Architecture call to get record from data base
DBCALL "SELECT", "ACRT", Cmd$
Dim sBuffer As String
Dim fn As Integer
Dim sbound As Boolean
fn = FreeFile
Open OPXCOM$ + "\MidRating.TXT" For Input As #fn
Do While Not EOF(fn)
Line Input #fn, sBuffer
' Input #fn, sBuffer
' CheckCreditFile = True
' End If
Loop
' If CheckCreditFile = False Then
' Print #18, BLOOMCNO
'*** Show PgUp, PgDn, Home, End buttons
'*** Pass successful return code back to calling routine
result = 0
MidRange_Exit:
Exit Function
MidRange_Error:
ErrorRoutine$ = "MidRange"
Gerr Err
End Function
the second part is where it sorts out the mid range value im looking for
Code:
Public Sub MidLevelPostNotched(iMoodys As Integer, iSP As Integer, iFitch As Integer)
Dim iHighest As Integer
Dim iArr As Variant
If iMoodys = 0 Or iSP = 0 Or iFitch = 0 Then
'get highest value
iHighest = iMoodys
sRatingAgency = MOODYS_TITLE
If iSP > iHighest Then
iHighest = iSP
sRatingAgency = SP_TITLE
End If
If iFitch > iHighest Then
iHighest = iFitch
sRatingAgency = FITCH_TITLE
End If
iMidLevelPostNotched = iHighest
Else
'get median value - Sort the array and get the mid value
iArr = Array(0, iMoodys, iSP, iFitch)
' Sort the Array and display the values in order.
BubbleSort iArr
iMidLevelPostNotched = iArr(2)
If iMidLevelPostNotched = iMoodys Then
sRatingAgency = MOODYS_TITLE
ElseIf iMidLevelPostNotched = iSP Then
sRatingAgency = SP_TITLE
ElseIf iMidLevelPostNotched = iFitch Then
sRatingAgency = FITCH_TITLE
End If
End If
End Sub
what im stuck with is what goes in my loop to fill in the iMoodys SP , iFitch in the second function so that it can sort out which value is the mid range value
-
August 14th, 2012, 08:35 AM
#2
-
August 14th, 2012, 09:03 AM
#3
Re: arrays
Please do no bump your posts. Someone will answer when they have a chance.
As for your issue why are you reading from the text file and using a bubble sort? You could simply sort the data with the SQL statement and have it returned in a recordset. No need for an array or a sort function.
What do you mean by medium value? Are you trying to find a value in the data that is 1/2 way between the highest and lowest? An Average value? What?
Always use [code][/code] tags when posting code.
-
August 14th, 2012, 09:22 AM
#4
Re: arrays
sorry bout double post
what i mean about medium is say my values coming in are 16, 16, 10 medium is 16 if the values come in are 10, 8, 9 medium is 8
i get what you mean bout the sql but there is other stuff happening in the code and this is the only way i can do it.
i just really need to figure out how if the values coming in are say 10, 8, 9 that imoodys pick up the 10 ifitch picks up the 8 etc then pass it into the sort to get the answer i want.
rest of the code its working perfectly just don't no what to put into the array to get it to pass of the values
-
August 14th, 2012, 11:17 AM
#5
Re: arrays
It would help to know who WROTE the code. You also call a BubbleSort() function, which isn't shown.
Also, a few lines of DATA would help.
Field#1_Name,Field#2_Name,Field#3_Name,Field#4_Name,Field#5_Name
x1, x2, x3, x4,x5
x1, x2, x3, x4,x5
x1, x2, x3, x4,x5
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
|