Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > help with arrays and textboxes on different forms


Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2002, 01:57 AM
The Ghost
Guest
 
Posts: n/a
Default help with arrays and textboxes on different forms


I have an array that i have loaded from a text file which is on a seperate form to a textbox which inputs new data into the text file when enter is pressed. I want it to put the new data into the text file only if the value is higher than the one below it. So i kind of need something to sort the values in a text file, thats the easy way of putting it. Any ideas guys? thanks for any help
Reply With Quote
  #2  
Old 09-30-2002, 02:16 AM
Hasin's Avatar
Hasin Hasin is offline
Centurion
 
Join Date: Sep 2002
Location: Bangladesh
Posts: 118
Default

Use this algorithm,

If your array name is a() then :-

Sub Sort
For i = lbound(a) to ubound(a)-1
For m = lbound(a) to ubound(a)-1
if a(m)>a(m+1) then
t=a(m+1)
a(m+1) = a(m)
a(m) = t
end if
next
next

open "c:\sorted.txt" for binary as #1
put #1,,a
close #1

end sub

# Now your array is sorted and writen. But this sorting is Bubble Sort and a bit time consuming
__________________
Hasin Hayder
http://www.vbsthopoti.cjb.net
Lead Programmer - EvelinDev
Things that are tough takes time - Things that are impossible takes a little more.
Reply With Quote
  #3  
Old 09-30-2002, 03:23 AM
The Ghost
Guest
 
Posts: n/a
Default

well whats m in this case???
Reply With Quote
  #4  
Old 09-30-2002, 03:26 AM
The Ghost
Guest
 
Posts: n/a
Default

also what if my array is a label would i just substitute this for 'a'
lblHSS ???

if i have stuffed up the following code please feel free to tell me where, thanks

Code:
Public Sub Sort() For i = LBound(lblHSS(i)) To UBound(lblHSS(i)) - 1 For m = LBound(lblHSS(i)) To UBound(lblHSS(i)) - 1 If Val(lblHSS(i)(m)) > Val(lblHSS(i)(m + 1)) Then t = Val(lblHSS(m + 1)) Val(lblHSS(i)(m + 1)) = Val(lblHSS(i)(m)) Val(lblHSS(i)(m)) = t End If Next Next Open App.Path & "/highscores.txt" For Binary As #1 Put #1, , lblHSS(i) Close #1 End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->