|
-
Oct 10th, 2000, 06:26 AM
#1
Thread Starter
Hyperactive Member
How can i sort the list box by value, i am using
List1.AddItem curChar & " " & occurred(Result.text, curChar)
to display results but wish to display highest value first.
Many Thanks
G.
-
Oct 10th, 2000, 06:37 AM
#2
_______
<?>
Code:
Sub SortNumbers(iArray As Variant)
Dim lLoop1 As Long
Dim lLoop2 As Long
Dim lTemp As Long
For lLoop1 = UBound(iArray) To LBound(iArray) Step -1
For lLoop2 = LBound(iArray) + 1 To lLoop1
If iArray(lLoop2 - 1) > iArray(lLoop2) Then
lTemp = iArray(lLoop2 - 1)
iArray(lLoop2 - 1) = iArray(lLoop2)
iArray(lLoop2) = lTemp
End If
Next lLoop2
Next lLoop1
End Sub
'
'I would load my numbers into and array, sort the array,
' and then load the listbox.
dim myfile as string
dim myArr
dim i as integer
Open myfile for input as #1
Do while not eof(#1)
input #1, myNum
redim preserve myArr(i)
myArr(i) = myNum
i = i + 1
loop
call SortNumbers(myArr)
For i = lbound(myArr) to ubound(myarr)
list1.additem myarr(i)
next i
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 10th, 2000, 08:07 AM
#3
transcendental analytic
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 10th, 2000, 08:38 AM
#4
Thread Starter
Hyperactive Member
VALUE
My value is returned in this way
List1.AddItem curChar & " " & occurred(Result.text, curChar)
how can i list the value of occurred(result.text,curChar) = ? before list1.additem....
Cheers
-
Oct 10th, 2000, 08:48 AM
#5
transcendental analytic
you want to sort the returnvalues of occurred? where did you get the occurred function from? I had replied to a thread of certain character occurrance in a string, where you get an array of all ascii chars count. Maybe that would be easier?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 10th, 2000, 09:22 AM
#6
Thread Starter
Hyperactive Member
HOW IT WORKS
The app works as follows: Opne a text file reads the contents, trims and removes chr$(10 and 13's) looks to see how many a's b's c's etc are in the text and reports it to a list box.
Many Thanks
-
Oct 10th, 2000, 09:38 AM
#7
transcendental analytic
http://forums.vb-world.net/showthrea...threadid=34475
Go here and get the code i wrote for you, you can use the array ASCII as you want, then make another array with the A-Z and then sort them parallel, go check the sortroutine thread of how to do that. Finally you add the arrays by index to the listbox
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 10th, 2000, 10:07 AM
#8
Thread Starter
Hyperactive Member
flippin eck ... whats going on here.. isnt it easier to modify the one below..?
--------------------------------------
Dim buffer() as byte, x&, ascii&(255)
Open File for binary as #1
Get#1,,buffer
close #1
For X=0 ubound(buffer)
ascii(buffer(x))=ascii(buffer(x))+1
next X
--------------------------------------
Private Sub command2_click()
Dim lne$
Dim x
Dim szTemp As String
Open "C:\mystery\mystery.txt" For Input As #1
szTemp = Input$(LOF(1), #1)
szTemp = TrimChar(szTemp, Chr$(10))
szTemp = TrimChar(szTemp, Chr$(13))
Result.text = szTemp
Close #1
Dim curChar As String
Dim counter As Integer
curChar = "a"
For counter = 1 To 26
If occurred(Result.text, curChar) != 0 Then
Debug.Print curChar & " " & occurred(Result.text, curChar)
List1.AddItem curChar & " " & occurred(Result.text, curChar)
End If
curChar = Chr(Asc(curChar) + 1)
Next counter
End Sub
-
Oct 10th, 2000, 11:14 AM
#9
transcendental analytic
No, it's easier to have an array, then you don't need to modify the sort method for the listbox, just make it swap the ASCII codes too.
Code:
'now this will only get the text chars in the array:
Dim buffer() as byte, x&, ascii&(255)
Open File for binary as #1
Get#1,,buffer
close #1
For X=0 ubound(buffer)
Y=Buffer(x)
If Y>=65 and Y<=90 then
ascii(buffer(x-65))=ascii(buffer(x-65))+1
End if
next X
'this will create the array for ascii codes
Dim Asciicode(25) as string
For X=0 to 25
asciicode(X)=asciicode(X)=chr(65+X)
Next X
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 11th, 2000, 04:04 AM
#10
Thread Starter
Hyperactive Member
PROBLEMS
I'm having great problems with this
Dim buffer() as byte, x&, ascii&(255)
Open File for binary as #1
Get#1,,buffer
close #1
For X=0 ubound(buffer)
Y=Buffer(x)
If Y>=65 and Y<=90 then
ascii(buffer(x-65))=ascii(buffer(x-65))+1
End if
next X
'this will create the array for ascii codes
Dim Asciicode(25) as string
For X=0 to 25
asciicode(X)=asciicode(X)=chr(65+X)
Next X
could you make this work please. my VB is not as sharp as my C
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
|