1,216
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Type MSHFlexGridRow
RowNo As String * 5
Cell1 As String * 20 '定义为定长字符串或其他类型,这个看你的具体情况而定
Cell2 As String * 20 '每个列定义一个元素
Cell3 As String * 20
Cell4 As String * 20
End Type
Dim RowRecord() As MSHFlexGridRow
Private Sub Command1_Click()
Dim intRow As Integer
Dim intFileNo As Integer
ReDim RowRecord(0 To MSHFlexGrid1.Rows - 1)
For intRow = 0 To MSHFlexGrid1.Rows - 1
RowRecord(intRow).RowNo = MSHFlexGrid1.TextMatrix(intRow, 0)
RowRecord(intRow).Cell1 = MSHFlexGrid1.TextMatrix(intRow, 1)
RowRecord(intRow).Cell2 = MSHFlexGrid1.TextMatrix(intRow, 2)
RowRecord(intRow).Cell3 = MSHFlexGrid1.TextMatrix(intRow, 3)
RowRecord(intRow).Cell4 = MSHFlexGrid1.TextMatrix(intRow, 4)
intFileNo = FreeFile
Open App.Path & "\1.txt" For Random As intFileNo Len = Len(RowRecord(intRow))
Put intFileNo, intRow + 1, RowRecord(intRow)
Close intFileNo
Next intRow
End Sub
Private Sub Form_Load()
Dim intRow As Integer
Dim intCol As Integer
Dim strP As String
With MSHFlexGrid1
.FixedRows = 1
.FixedCols = 1
.Rows = 100
.Cols = 4
.FormatString = "^序号|列1|^列2|^列3|^列4"
End With
For intRow = 1 To 99
For intCol = 0 To 4
Select Case intCol
Case 0
strP = intRow
Case 1
strP = "中"
Case 2
strP = "国"
Case 3
strP = "人"
Case 4
strP = "强"
End Select
MSHFlexGrid1.TextMatrix(intRow, intCol) = strP
Next intCol
Next intRow
End Sub