且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

字符串中的分隔值

更新时间:2023-02-21 17:50:46

好的,我想我理解您的要求.

您已经从ini文件中获取了信息,但是想存储此信息以备将来使用?

Ok I think I understand what your asking about.

You have already got the information from your ini file, but want to store this info to do what you will with later?

Public Class Merchant
    Public bVisible As Boolean 'To hold 1st comma value (Boolean)
    Public strID As String 'To hold 2nd comma value (String)
    Public strDesc As String

    Public Sub New(ByVal p_visible As Boolean, ByVal p_id As String, ByVal p_desc As String)
        bVisible = p_visible
        strID = p_id
        strDesc = p_desc
    End Sub

End Class



这是保存单个商人详细信息的简单类.

您可以使用以下商家字典.



That is a simple class to hold the details of a single merchant.

You could use a dictionary of merchants as below.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim merchants As Dictionary(Of String, Merchant)

       merchants = New Dictionary(Of String, Merchant)()

       merchants.Add("MERCH1", New Merchant(True, "P", "PAYMENT")) 'MERCH1=1,P,PAYMENT
       merchants.Add("MERCH2", New Merchant(False, "R", "ROADTAX")) 'MERCH2=0,R,ROADTAX
       merchants.Add("MERCH3", New Merchant(True, "S", "SUMMON")) 'MERCH3=1,S,SUMMON

       Dim merch3 As Merchant = merchants("MERCH3")
       MsgBox(merch3.strDesc)

   End Sub



您可以看到这种方式,您只需要告诉商人词典您要处理的商人即可.

希望这会有所帮助!



You can see that way you just need to tell the Dictionary of Merchants which Merchant you want to deal with.

Hope this helps!