# problem in sort sequintial file in vesual basic

Page 1 of 1

## 2 Replies - 1262 Views - Last Post: 05 November 2007 - 11:37 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=36715&amp;s=3f28027aeb98620092376dd777834936&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 momy

Reputation: 0
• 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

• Student of Life

Reputation: 423
• 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.

### #3 momy

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

## Re: problem in sort sequintial file in vesual basic

Posted 05 November 2007 - 11:37 AM

jayman9, 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.