News:

Ramadan Mubarak!

I pray that we get the full blessings of Ramadan and may Allah (SWT) grant us more blessings in the year to come.
Amin Summa Amin.

Ramadan Kareem,

Main Menu

VB .Net

Started by Ihsan, November 11, 2004, 04:45:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ihsan

Here is a simple program that asks the user for 5 numbers then display the numbers in the first column, display the numbers in reverse in the second column, and display the average in the 3rd column.

Option Strict On
Module Module1
   
   Sub Main()
       Dim nums(4, 2) As Integer, i As Integer, j As Integer, k As Integer, Avg As Double, l As Integer
       Console.WriteLine("Please enter 5 numbers")

       For i = 0 To 4
           nums(i, 0) = CInt(Console.ReadLine())
       Next i
       Console.WriteLine("Stop")

       For j = 0 To 4
           nums(j, 1) = nums((4 - j), 0)
       Next

       For k = 0 To 4
           Avg = (nums(k, 0) + nums(k, 1)) / 2
           nums(k, 2) = CInt(Avg)
       Next

       For l = 0 To 4
           Console.WriteLine(nums(l, 0) & " " & nums(l, 1) & " " & nums(l, 2))
       Next

       Console.ReadLine()
       
   End Sub

End Module
greetings from Ihsaneey

Ihsan

Another program that ask the user for a word and then it translates it into some kind of code

Option Strict On
Module Question4
   Sub main()
       Dim word, letter, morse As String, i As Integer
       Console.WriteLine("Please enter a word")
       word = UCase(Console.ReadLine)

       For i = 1 To Len(word)
           letter = Mid(word, i, 1)
           Select Case letter
               Case "A"
                   morse = morse + "._"
               Case "B"
                   morse = morse + "_..."
               Case "C"
                   morse = morse + "_._."
               Case "D"
                   morse = morse + "_.."
               Case "E"
                   morse = morse + "."
               Case "F"
                   morse = morse + ".._."
               Case "G"
                   morse = morse + "_ _."
               Case "H"
                   morse = morse + "...."
               Case "I"
                   morse = morse + ".."
               Case "J"
                   morse = morse + "._ _ _"
               Case "K"
                   morse = morse + "_._"
               Case "L"
                   morse = morse + "._.."
               Case "M"
                   morse = morse + "_ _"
               Case "N"
                   morse = morse + "_."
               Case "O"
                   morse = morse + "_ _ _"
               Case "P"
                   morse = morse + "._ _."
               Case "Q"
                   morse = morse + "_ _._"
               Case "R"
                   morse = morse + "._."
               Case "S"
                   morse = morse + "..."
               Case "T"
                   morse = morse + "_"
               Case "U"
                   morse = morse + ".._"
               Case "V"
                   morse = morse + "..._"
               Case "W"
                   morse = morse + "._ _"
               Case "X"
                   morse = morse + "_.._"
               Case "Y"
                   morse = morse + "_._ _"
               Case "Z"
                   morse = morse + "_ _.."
           End Select
       Next
       Console.WriteLine("The word " & word & " in Morse code is " & morse)
       Console.ReadLine()
   End Sub
End Module
greetings from Ihsaneey

Ihsan

This one counts the number of words in a sentence


Dim MyText As String = "Ramadan Kareem from Ihsan"
       Dim position, words As Integer
       position = 1
       Do While position > 0
           position = InStr(position + 1, MyText, " ")
           words = words + 1
       Loop
       Console.WriteLine("There are " & words & " words in the text")

       Console.ReadLine()
   End Sub
greetings from Ihsaneey

_Waziri_

Will try to see how I can all these in Pascal  God willing.

Anonymous

_Waziri_ I definitely agree with your words.