我刚刚学VB不久谁能帮我解决下问题
请问一下Private Sub Command2_Click()
Dim ayxinxi(10) As Class1
Dim i As Integer
Grid1.Rows = 11
Grid1.Cols = 6
Grid1.Row = 0
Grid1.Col = 0
Grid1.Text = "编号"
Grid1.Row = 0
Grid1.Col = 1
Grid1.Text = "客户名称"
Grid1.Row = 0
Grid1.Col = 2
Grid1.Text = "地址"
Grid1.Row = 0
Grid1.Col = 3
Grid1.Text = "注册资金"
Grid1.Row = 0
Grid1.Col = 4
Grid1.Text = "联系人"
Grid1.Row = 0
Grid1.Col = 5
Grid1.Text = "联系电话"
For i = 1 To 10
Set ayxinxi(i) = New Class1
ayxinxi(i).name = "南砼公司"
ayxinxi(i).address = "湖滨北路"
ayxinxi(i).money = 100 * i
ayxinxi(i).person = "李先生"
ayxinxi(i).phone = "11111"
Grid1.Row = i
Grid1.Col = 0
Grid1.Text = CStr(i)
Grid1.Row = i
Grid1.Col = 1
Grid1.Text = ayxinxi(i).name
Grid1.Row = i
Grid1.Col = 2
Grid1.Text = ayxinxi(i).address
Grid1.Row = i
Grid1.Col = 3
Grid1.Text = ayxinxi(i).money
Grid1.Row = i
Grid1.Col = 4
Grid1.Text = ayxinxi(i).person
Grid1.Row = i
Grid1.Col = 5
Grid1.Text = ayxinxi(i).phone
Next i
End Sub
输出的结果 表中都以样的信息 我想让表中的信息安我的数据 自动输入 该怎么做 我用的事MSHFlexGrid控件
我想要让下面输入信息 但是不一样要怎么做到啊
前面我又定义一个类模块 --------------------编程问答--------------------
Set ayxinxi(i) = New Class1
Dim ayxinxi(10) As Class1
你这是哪里学的VB啊?怎么会这样定义数组?这样能运行吗?
Dim ayxinxi(10) As String
这样定义。 --------------------编程问答-------------------- Dim ayxinxi(10) As Class1
这样定义是不对的。
--------------------编程问答-------------------- 你可以用N种方法在MSHFLEXGRID中添加记录:
1: 你的方法即可, 至于为什么记录都是一样的,那是因为你每次添加的信息本来就是一样的
2: 用Grid.textMatrix(ROW,COL)=XXX的方法直接定位并赋值
3: 先不指定GRID行数, 然后直接用Grid.ADDITEM 的方法添加整行记录
4: 算好总的格子的数量, 设定好Grid的行列数, 然后用Grid.List(I)=XXX的方法按行扫描添加数据
5: 设置好行数和列数, 然后先构建一个字符串, 字符串格式按照相邻格子用Chr(9)分隔,行间用Chr(13)分割, 最后一次性用Grid.Clip方法批量导入数据
例子不给了, MSDN上查一下吧. --------------------编程问答-------------------- Dim ayxinxi(10) As Class1
这不是VB的语法吧。你的程序能运行吗?
补充:VB , 基础类