how to create a Visual basic application for the question

Apraku Ofori 0 Reputation points
2023-03-11T16:51:58.9966667+00:00

According to the 2020 population figures, the Northern Region has a population of 2,479,461 representing 10.1% with a growth rate of 2%. Create a Visual basic application that will output the estimate population figures for the northern region

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,555 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 26,106 Reputation points Microsoft Vendor
    2023-03-13T06:05:53.6066667+00:00

    Hi @Apraku Ofori ,

    You can refer to the following code. Console App.

    Module Program
        Sub Main(args As String())
            Dim Population As Integer = 2479461
            For i = 0 To 10 Step 1
                Console.WriteLine((2020 + i).ToString + " , " + (Population).ToString)
                Population = Population * 1.101
            Next
            Console.ReadLine()
        End Sub
    End Module
    

    WinForm App.

    Imports System.Windows.Forms.DataVisualization.Charting
    
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim dgv1 As New DataGridView
            dgv1.Location = New Point(0.0)
            dgv1.Enabled = False
            Me.Controls.Add(dgv1)
            dgv1.Width = 240
            dgv1.Height = 400
            Dim dt As New DataTable
            dt.Columns.Add("Year", GetType(Integer))
            dt.Columns.Add("Population", GetType(Integer))
    
            Dim Chart1 As New Chart
            Chart1.Location = New Point(240, 0)
            Chart1.Width = 400
            Chart1.Height = 400
            Me.Controls.Add(Chart1)
            Chart1.Series.Add(New Series)
            Chart1.ChartAreas.Add(New ChartArea)
            Chart1.Series(0).BorderWidth = 2
            Chart1.Series(0).Color = Color.Red
            Chart1.Series(0).ChartType = SeriesChartType.Line
            Chart1.ChartAreas(0).AxisX.MajorGrid.Enabled = False
            Chart1.ChartAreas(0).AxisY.Minimum = 2400000
            Chart1.ChartAreas(0).AxisY.Maximum = 6500000
            Chart1.ChartAreas(0).AxisX.Minimum = 2020
            Chart1.ChartAreas(0).AxisX.Maximum = 2030
    
            Dim Population As Integer = 2479461
            For i = 0 To 10 Step 1
                dt.Rows.Add(2020 + i, Population)
                Population = Population * 1.101
                Chart1.Series(0).Points.AddXY(2020 + i, Population)
            Next
            dgv1.DataSource = dt
        End Sub
    End Class
    

    Best Regards.

    Jiachen Li
    ----------
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments