VB.NET中模块和表单之间的数据交换 [英] Data exchange between module and form in VB.NET

查看:118
本文介绍了VB.NET中模块和表单之间的数据交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些代码来读取fileconfig的内容。

它位于一个表单中。

我想,一旦数据被提取,插入它们form1中的列表框



这是代码



我尝试过的方法:



I wrote some code to read the contents of the fileconfig.
This resides in a form.
I would like, once the data is extracted, insert them in a listbox in the form1

this is the code

What I have tried:

Module ModuloConfig

    Sub MainConfig()
        ReadAllSettings() ' legge tutto il contenuto dell' app setting
     end sub  

    Sub ReadAllSettings() ' legge tutto l' appsetting
        Try
            Dim appSettings = ConfigurationManager.AppSettings

            If appSettings.Count = 0 Then
                Console.WriteLine("AppSettings is empty.") ' è vuoto
            Else
                For Each key As String In appSettings.AllKeys 'legge tutte le key
                    Console.WriteLine("Key: {0} Value: {1}", key, appSettings(key))

                Next
            End If
        Catch e As ConfigurationErrorsException
            Console.WriteLine("Error reading app settings")
        End Try
    End Sub
End Module

推荐答案

请按照: ListBox.ObjectCollection.Add(Object)方法(System.Windows.Forms)| Microsoft Docs [ ^ ]


我的问题不是创建一个列表框,而是将表单中的数据传输到表单中的列表框。也许通过函数调用



i想要传输这个:
my problem is not to create a list box but to transfer the data I got in the form to the listbox that is in the form. Maybe through a function call

i want to trasfert this:
key, appSettings(key)


这篇关于VB.NET中模块和表单之间的数据交换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆