Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Dim mylist() As Integer = {25, 34, 98, 7, 41, 19, 5}

Dim temp As Integer


'Dim maxindex As Integer = 6
'Dim nomoreswaps As Boolean
'' n = maxindex - 1
For x = 1 To 6
For j = 0 To 5
If mylist(j) > mylist(j + 1) Then
temp = mylist(j)
mylist(j) = mylist(j + 1)
mylist(j + 1) = temp

End If
Next j
Next x

For x = 0 To 6
Console.WriteLine(mylist(x))
Next
Console.ReadKey()

Sub Main()
Dim mylist() As Integer = {25, 34, 98, 7, 41, 19, 5}
Dim n, j, temp As Integer
Dim maxindex As Integer = 6
Dim nomoreswaps As Boolean
n = maxindex - 1
Do
nomoreswaps = True
For j = 0 To n
If mylist(j) > mylist(j + 1) Then
temp = mylist(j )
mylist(j) = mylist(j + 1)
mylist(j + 1) = temp
nomoreswaps = False

End If
Next j
n = n - 1
Loop Until nomoreswaps = True
For x = 0 To 6
Console.WriteLine(mylist(x))
Next
Console.ReadKey()
Read

Dim yamini As String


Dim age As New IO.StreamReader("c:\users\ratta\desktop\abc.txt")
yamini = age.ReadLine
'Do While Not yamini Is Nothing
Do While age.Peek <> -1
Console.WriteLine(yamini)
yamini = age.ReadLine
Loop
age.Close()
Console.ReadKey()

Write
Dim name, age, sect As String
Dim filehandle As New IO.StreamWriter("c:\users\ratta\desktop\abc.txt")
Console.WriteLine("ënter age")
age = Console.ReadLine
While age <> "-1"

Console.WriteLine("enter name")
name = Console.ReadLine
Console.WriteLine("enter sect")
sect = Console.ReadLine
filehandle.WriteLine(name & ":" & age & ":" & sect)
Console.WriteLine("enter age")
age = Console.ReadLine

End While
filehandle.Close()

You might also like