首页 > 解决方案 > 不懂做visual basic显示国家和城市的项目

问题描述

屏幕截图所以目前我正在尝试创建一个应用程序,其中有两个列表框,一个显示国家/地区,一个显示这些国家/地区的城市。单击列表框中的城市后,richtextbox 将以特定格式显示信息,这与我提供的屏幕截图相同。然后,图片框将提供该城市的图片。还有两个标签:人口和降雨量,它显示了它的统计信息,但是当我单击列表框中的城市时,我不知道如何触发它。另外,我想知道如何通过复选框使文本字体变大和变小,当然是BY CODE。我目前正在编写代码,但似乎我无处可去。

Public Class frmWorldCities
    '---------------------------------------------------
    'Description: Class-wide declarations
    '
    'Calls: fNumOfFiles
    '---------------------------------------------------

    Const cstrPath As String = "..\Data\gldfiles\"
    Dim CIntNumofFiles As Integer = 78
    Dim cstrFileNames(CIntNumofFiles - 1) As String
    Dim cintFileLines(CIntNumofFiles - 1) As Integer
    Dim cstrCityNames(CIntNumofFiles - 1) As String
    Dim cstrFileCountryNames(CIntNumofFiles - 1) As String
    Dim cstrPopulation(CIntNumofFiles - 1) As String
    Dim cstrRainfall(CIntNumofFiles - 1) As String
    Dim cstrInformation(CIntNumofFiles - 1) As String
    Dim cstrPictureName(CIntNumofFiles - 1) As String

    Private Sub frmWorldCities_Load(sender As Object, e As EventArgs) Handles Me.Load
        '---------------------------------------------------------------------------
        'Description: how the application should display while opening.
        '---------------------------------------------------------------------------

        Dim strTemp As String = ""
        Dim intLines As Integer
        Dim i As Integer
        Dim j As Integer

        FileOpen(1, cstrPath & "list.wcf", OpenMode.Input)

        Input(1, strTemp)
            intLines = CInt(strTemp)

        For i = 0 To intLines - 2
            Input(1, cstrFileNames(i))
            lstCities.Items.Add(cstrFileNames(i))
        Next i
        FileClose(1)

        For i = 0 To cstrFileNames.Length - 1
            FileOpen(1, cstrPath & cstrFileNames(i), OpenMode.Input)
            Input(1, strTemp)
            cintFileLines(i) = CInt(strTemp)
            cstrCityNames(i) = LineInput(1)
            Input(1, strTemp)
            Input(1, cstrFileCountryNames(i))
            cstrPopulation(i) = LineInput(1)
            Input(1, cstrRainfall(i))
            Input(1, strTemp)

            For j = 0 To cintFileLines(i) - 10
                strTemp = LineInput(1)
                cstrInformation(i) &= strTemp & Chr(13)
            Next j

            Input(1, strTemp)
            Input(1, cstrPictureName(i))

            FileClose(1)
        Next i
    End Sub

    Private Sub lstCountries_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstCountries.SelectedIndexChanged
        '------------------------------------
        'Description: listing the cities.
        '------------------------------------
        Dim i As Integer
        lstCities.Items.Clear()

        For i = 0 To cstrCityNames.Length - 1
            If lstCountries.SelectedItem.ToString = cstrFileCountryNames(i) Then
                lstCities.Items.Add(cstrCityNames(i))
            End If
        Next i


    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        ' To close the application
        Me.Close()
    End Sub

    Private Sub chkBold_CheckedChanged(sender As Object, e As EventArgs) Handles chkBold.CheckedChanged
        ' To make the information bold.
        If chkBold.Checked = True Then
            rtbInformation.Font = New Font(rtbInformation.Font, FontStyle.Bold)
        Else
            rtbInformation.Font = New Font(rtbInformation.Font, FontStyle.Regular)
        End If
    End Sub

    Private Sub chkItalic_CheckedChanged(sender As Object, e As EventArgs) Handles chkItalic.CheckedChanged
        If chkItalic.Checked = True Then
            rtbInformation.Font = New Font(rtbInformation.Font, FontStyle.Italic)
        Else
            rtbInformation.Font = New Font(rtbInformation.Font, FontStyle.Regular)
        End If
    End Sub

    Private Sub chkBiggerFont_CheckedChanged(sender As Object, e As EventArgs) Handles chkBiggerFont.CheckedChanged
        If chkBiggerFont.Checked = True Then
            rtbInformation.Font = New Font(rtbInformation.Font, FontStyle.Strikeout)
        End If
    End Sub

    Private Sub chkSmallerFont_CheckedChanged(sender As Object, e As EventArgs) Handles chkSmallerFont.CheckedChanged

    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles picCities.Click

    End Sub
End Class

标签: vb.net

解决方案


推荐阅读