其他结构的阵列结构 [英] Array Structure in other Structure

查看:80
本文介绍了其他结构的阵列结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Public Class Form1
    Dim List(15) As Record

    Structure Record

        Dim Caption As String
'may be i cant do that anyone help me??
        Dim Accounts() As SturAccount

    End Structure

    Structure SturAccount
        Dim Name As String
        Dim Pw As String
    End Structure

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim EachAccounts(4) As SturAccount

        EachAccounts(0).Name = "123"
        EachAccounts(0).Pw = "123"

        EachAccounts(1).Name = "fai"
        EachAccounts(1).Pw = "789"

        For i As Integer = 0 To 1
            List(i).Caption = 10
            For j As Integer = 0 To 1
                   'Error here. i dont know why.
              List(i).Accounts(j).Name = EachAccounts(j).Name
             List(i).Accounts(j).Pw = EachAccounts(j).Pw
            Next
        Next
    End Sub
End Class

推荐答案

如果您告诉我们错误是什么,它将有所帮助.但是,我会说Accounts(j)为null,需要先创建Accounts(j),然后才能对其设置值.
If you told us what the error was, it would help. But, I''d say that Accounts(j) is null and needs to be created before you can set values on it.


这篇关于其他结构的阵列结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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