none
Programming With Visual Basic RRS feed

  • Question

  • Please Someone should help answer this nagging questions using the most simplest elementary methods for a newbie/beginner in Visual Basic.

    I will greatly appreciate it thanks. !

     

    1.        Write a Program that Inputs one number consisting of five digits from the user, separates the number into its individual digits  and prints the digits separated from one another by three spaces each. For Example, If the user types in the number  42339, the program should display:

    4   2   3   3   9

    Hint: You will need to use both the integer division and modulus operation to “pick off” each digit.

    2.        Write an application that reads five integers and determines and prints the largest and the smallest integers in the group.

    Thank You Very Much Great Programmers and Potential   GMSTs,   I Love You All!


    ForceField
    • Edited by GMST Tuesday, November 23, 2010 2:35 PM
    Wednesday, November 17, 2010 12:01 PM

Answers

  • Compile these modules into Console Applications

    1.
    Module MainModule
      Dim Text, Display As String
      Sub Main()'Program starts from Sub Main()
        Text = "42339"
        'TextWindow is Console in Visual Basic
        Console.WriteLine(Text)
        For I = 1 To Text.Length
          Display = Display + " " + Text.Substring(I - 1, 1)
        Next'EndFor is Next in Visual Basic
        Console.WriteLine(Display)
        Console.ReadLine()
      End Sub
    End Module


    2.
    Module MainModule
      Dim numbers(0 To 4), max, min As Integer
      Sub Main()
        numbers(0) = 9
        numbers(1) = 3
        numbers(2) = 2
        numbers(3) = -5
        numbers(4) = 8
        max = numbers(0)
        min = numbers(0)
        For i = 0 To 4 'Number of items in array
          max = Math.Max(numbers(i), max)
          min = Math.Min(numbers(i), min)
        Next
        Console.WriteLine("Max: " + max.ToString())
        Console.WriteLine("Min: " + min.ToString())
        Console.Read()
      End Sub
    End Module


    Sorry My Bad English
    Tuesday, November 23, 2010 4:06 PM

All replies

  • 1.

    text = "42339"

    TextWindow.WriteLine(text)

    For i = 1 To Text.GetLength(text)

     char = Text.GetSubText(text,i,1)

     display = Text.Append(display,"   " + char)

    EndFor

    TextWindow.WriteLine(display)

     

    2.

    numbers[1] =9

    numbers[2] = 3

    numbers[3] = 2

    numbers[4] = -5

    numbers[5] = 8

    max = numbers[1]

    min = numbers[1]

    For i = 1 To Array.GetItemCount(numbers)

     max = Math.Max(numbers[i],max)

     min = Math.Min(numbers[i],min)

    EndFor

    TextWindow.WriteLine("Max: " + max)

    TextWindow.WriteLine("Min: " + min)

    Wednesday, November 17, 2010 9:50 PM
  • You are too much nickm_BR. Your program is OK and Nice. But Can you please rewrite this beautiful program of yours in visual basic using the most simplest elementary methods for a newbie/beginner.

    I will greatly appreciate it thanks.


    ForceField
    Tuesday, November 23, 2010 2:28 PM
  • Compile these modules into Console Applications

    1.
    Module MainModule
      Dim Text, Display As String
      Sub Main()'Program starts from Sub Main()
        Text = "42339"
        'TextWindow is Console in Visual Basic
        Console.WriteLine(Text)
        For I = 1 To Text.Length
          Display = Display + " " + Text.Substring(I - 1, 1)
        Next'EndFor is Next in Visual Basic
        Console.WriteLine(Display)
        Console.ReadLine()
      End Sub
    End Module


    2.
    Module MainModule
      Dim numbers(0 To 4), max, min As Integer
      Sub Main()
        numbers(0) = 9
        numbers(1) = 3
        numbers(2) = 2
        numbers(3) = -5
        numbers(4) = 8
        max = numbers(0)
        min = numbers(0)
        For i = 0 To 4 'Number of items in array
          max = Math.Max(numbers(i), max)
          min = Math.Min(numbers(i), min)
        Next
        Console.WriteLine("Max: " + max.ToString())
        Console.WriteLine("Min: " + min.ToString())
        Console.Read()
      End Sub
    End Module


    Sorry My Bad English
    Tuesday, November 23, 2010 4:06 PM