problem in sort sequintial file in vesual basic

i don't know what the problem please help me

Page 1 of 1

2 Replies - 1239 Views - Last Post: 05 November 2007 - 11:37 AM Rate Topic: -----

#1 momy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-November 07

problem in sort sequintial file in vesual basic

Posted 03 November 2007 - 01:52 PM

Private Sub Command9_Click()
Dim Fname As String
Dim Lname As String
Dim Age As Integer
Dim First(1 To 20) As String
Dim Last(1 To 20) As String
Dim agearrey(1 To 20) As Integer
Dim n As Integer
Dim Filenumber As Integer
Dim s As String
Dim Firsttemp As String
Dim Lasttemp As String
Dim Agetemp As Integer
Dim x As Integer
Dim y As Integer
Filenumber = FreeFile()
s = InputBox("ادخل اسم الملف", "اسم الملف")
n = 1
If s <> "" Then
Open s For Input As #Filenumber
If EOF(Filenumber) Then MsgBox ("the aeeey emptey")
Do While Not EOF(Filenumber)
Input #Filenumber, First(n), Last(n), agearrey(n)
n = n + 1
Loop
For x = 1 To n - 2 Step 1
 For y = x + 1 To n - 1 Step 1
  If First(x) > First(y) Then
   Firsttemp = First(x)
   First(x) = First(y)
   First(y) = Firsttemp
   
   Lasttemp = Last(x)
   Last(x) = Last(y)
   Last(y) = Lasttemp
   
   Agetemp = agearrey(x)
   agearrey(x) = agearrey(y)
   agearrey(y) = Agetemp
   
   Else
	If First(x) = First(y) Then
	 If Last(x) > Last(y) Then
	  Firsttemp = First(x)
	  First(x) = First(y)
	  First(y) = Firsttemp
	  
	  Lasttemp = Last(x)
	  Last(x) = Last(y)
	  Last(y) = Lasttemp
	  
	  Agetemp = agearrey(x)
	  agearrey(x) = agearrey(y)
	  agearrey(y) = Agetemp
	  
	Else
	If Last(x) = Last(y) Then
	 If agearrey(x) > agearrey(y) Then
	  Firsttemp = First(x)
	  First(x) = First(y)
	  First(y) = Firsttemp
	  
	  Lasttemp = Last(x)
	  Last(x) = Last(y)
	  Last(y) = Lasttemp
	  
	  Agetemp = agearrey(x)
	  agearrey(x) = agearrey(y)
	  agearrey(y) = Agetemp
	  
	  End If
	End If
  End If
Next y
Next x

Close #Filenumber
End If

Open s For Input As #Filenumber
Do While Not EOF(Filenumber)
Input #Filenumber, Fname, Lname, Age
 Fname = First(n)
 Lname = Last(n)
 Age = agearrey(n)
Loop
Close #Filenumber
End If
End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: problem in sort sequintial file in vesual basic

#2 Jayman   User is offline

  • Student of Life
  • member icon

Reputation: 421
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: problem in sort sequintial file in vesual basic

Posted 03 November 2007 - 05:48 PM

Please describe the problem that you are having and include any error messages or unexpected output that you are getting.
Was This Post Helpful? 0
  • +
  • -

#3 momy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 03-November 07

Re: problem in sort sequintial file in vesual basic

Posted 05 November 2007 - 11:37 AM

View Postjayman9, on 3 Nov, 2007 - 05:48 PM, said:

Please describe the problem that you are having and include any error messages or unexpected output that you are getting.


hello thanks for your reply
the error massege is "Next without for "
and i try so mutch things put it not working
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1