如何在列表视图TRANSPOSE(移调)数据垂直 [英] How to tranpose data in listview vertically
问题描述
我在VB6的初学者。我的项目,现在是解析原始数据和只得到所需要的数据,并将其保存为CSV文件。我已经可以解析原料,并在列表中查看查看我的问题是数据会被水平列表视图输入,当我在看CSV文件,它是在相同的列表视图。
我现在的问题是我怎么可以把数据列表视图垂直
而我分析数据?
下面是在列表视图输出解析数据之后
这是我的code把数据列表视图
如果cmd_req_flow<> 而cmd_req_flow_a<> 然后
txt_date = cmd_date_time_a
txt_parsereq = cmd_totalparsedreq_a - cmd_totalparsedreq
txt_flowtotal = cmd_flow_total_a
txt_reqflow = cmd_req_flow_a
txt_aia = cmd_aia_a - cmd_aia
txt_air = cmd_air_a - cmd_air
txt_cer = cmd_cer_a - cmd_cer
txt_cla = cmd_cla_a - cmd_cla
txt_clr = cmd_clr_a - cmd_clr
txt_dsa = cmd_dsa_a - cmd_dsa
txt_dsr = cmd_dsr_a - cmd_dsr
txt_dwa = cmd_dwa_a - cmd_dwa
txt_dwr = cmd_dwr_a - cmd_dwr
txt_ida = cmd_ida_a - cmd_ida
txt_idr = cmd_idr_a - cmd_idr
txt_noa = cmd_noa_a - cmd_noa
txt_nor = cmd_nor_a - cmd_nor
txt_pua = cmd_pua_a - cmd_pua
txt_pur = cmd_pur_a - cmd_pur
txt_rsa = cmd_rsa_a - cmd_rsa
txt_rsr = cmd_rsr_a - cmd_rsr
txt_ula = cmd_ula_a - cmd_ula
txt_ulr = cmd_ulr_a - cmd_ulr 设置itmX = ListView1.ListItems.Add(,txt_date)
itmX.SubItems(1)= txt_parsereq
itmX.SubItems(2)= txt_flowtotal
itmX.SubItems(3)= txt_reqflow
itmX.SubItems(4)= txt_aia
itmX.SubItems(5)= txt_air
itmX.SubItems(6)= txt_cer
itmX.SubItems(7)= txt_cla
itmX.SubItems(8)= txt_clr
itmX.SubItems(9)= txt_dsa
itmX.SubItems(10)= txt_dsr
itmX.SubItems(11)= txt_dwa
itmX.SubItems(12)= txt_dwr
itmX.SubItems(13)= txt_ida
itmX.SubItems(14)= txt_idr
itmX.SubItems(15)= txt_noa
itmX.SubItems(16)= txt_nor
itmX.SubItems(17)= txt_pua
itmX.SubItems(18)= txt_pur
itmX.SubItems(19)= txt_rsa
itmX.SubItems(20)= txt_rsr
itmX.SubItems(21)= txt_ula
itmX.SubItems(22)= txt_ulr
呼叫clear_fourth
呼叫clear_five
呼叫clear_first 呼叫clear_field_name
呼叫clear_value
txt_sec = 0
txt_t1 =
txt_t2 =
txt_st = cmd_date_time = cmd_date_time_a
cmd_ulr = cmd_ulr_a
cmd_aia = cmd_aia_a
cmd_dsa = cmd_dsa_a
cmd_rsr = cmd_rsr_a
cmd_dsr = cmd_dsr_a
cmd_noa = cmd_noa_a
cmd_pur = cmd_pur_a
cmd_dwa = cmd_dwa_a
cmd_clr = cmd_clr_a
cmd_cla = cmd_cla_a
cmd_nor = cmd_nor_a
cmd_pua = cmd_pua_a
cmd_totalparsedreq = cmd_totalparsedreq_a
cmd_rsa = cmd_rsa_a
cmd_air = cmd_air_a
cmd_ida = cmd_ida_a
cmd_ula = cmd_ula_a
cmd_cer = cmd_cer_a
cmd_flow_total = cmd_flow_total_a
cmd_idr = cmd_idr_a
cmd_dwr = cmd_dwr_a
cmd_req_flow = cmd_req_flow_a
呼叫clear_second
万一
到MSFlexGrid控件添加到您的表单,你首先必须添加,您可以在菜单中进行的组成部分。
在项目菜单中点击组件并在那里检查微软FlexGrid控制
然后看看下面的测试项目:
1表格:
MSFlexGrid控件:名称= MSFlexGrid1
命令按钮:名称=指令
显式的选项私人小组Command1_Click()
静态lngMode只要
过程的正确方式
选择案例lngMode
案例0
FillHorizontal
情况1
FillVertical
案例2
FillData
结束选择
接着设置模式
lngMode =(lngMode + 1)模3
结束小组私人小组的Form_Load()
随着MSFlexGrid1
.FixedRows = 0
.FixedCols = 0
.Rows = 7
.Cols = 12
结束与MSFlexGrid1
结束小组私人小组Form_Resize()
昏暗sngWidth单,sngHeight单
昏暗sngCmdHeight单,sngGrdHeight单
sngWidth = ScaleWidth
sngHeight = ScaleHeight
sngCmdHeight = 495
sngGrdHeight = sngHeight - sngCmdHeight
MSFlexGrid1.Move 0,0,sngWidth,sngGrdHeight
Command1.Move 0,sngGrdHeight,sngWidth,sngCmdHeight
结束小组私人小组FillHorizontal()
昏暗lngRow长,lngCol只要
随着MSFlexGrid1
对于lngCol = 0〜.Cols - 1
对于lngRow = 0〜.Rows - 1
.TextMatrix(lngRow,lngCol)= CStr的(lngRow * .Cols + lngCol)
接下来lngRow
接下来lngCol
结束与MSFlexGrid1
结束小组私人小组FillVertical()
昏暗lngRow长,lngCol只要
随着MSFlexGrid1
对于lngCol = 0〜.Cols - 1
对于lngRow = 0〜.Rows - 1
.TextMatrix(lngRow,lngCol)= CStr的(lngCol * .Rows + lngRow)
接下来lngRow
接下来lngCol
结束与MSFlexGrid1
结束小组私人小组FillData()
随着MSFlexGrid1
。明确
.TextMatrix(0,0)=民以食为天
.TextMatrix(0,1)=饮料
.TextMatrix(1,0)=蛋糕
.TextMatrix(1,1)=水
.TextMatrix(2,0)=世界杯蛋糕
.TextMatrix(2,1)=软饮料
.TextMatrix(3,0)=面条
.TextMatrix(3,1)=橙汁
.TextMatrix(4,0)=广州
.TextMatrix(4,1)=咖啡
.TextMatrix(5,0)=Abodo
.TextMatrix(5,1)=茶经
结束与MSFlexGrid1
结束小组
当您单击该按钮会先水平填补了网格,当您再次单击该按钮,将垂直填补网格,当您再次单击该按钮将填补电网的一些数据
,请注意使用lngRow和lngCol以及它如何影响立式充填的水平
I am a beginner in VB6. My project right now is to parse a raw data and get only the needed data and save it as CSV file. I can already parse the raw and viewed in list view my problem is the data will inputted horizontally in listview and when i viewed it in CSV file the is same as the listview.
My question now is how can i put the data in listview vertically
while i parse the data?
below is the output in listview after parsing data
This is my code to put the data in listview
If cmd_req_flow <> "" And cmd_req_flow_a <> "" Then
txt_date = cmd_date_time_a
txt_parsereq = cmd_totalparsedreq_a - cmd_totalparsedreq
txt_flowtotal = cmd_flow_total_a
txt_reqflow = cmd_req_flow_a
txt_aia = cmd_aia_a - cmd_aia
txt_air = cmd_air_a - cmd_air
txt_cer = cmd_cer_a - cmd_cer
txt_cla = cmd_cla_a - cmd_cla
txt_clr = cmd_clr_a - cmd_clr
txt_dsa = cmd_dsa_a - cmd_dsa
txt_dsr = cmd_dsr_a - cmd_dsr
txt_dwa = cmd_dwa_a - cmd_dwa
txt_dwr = cmd_dwr_a - cmd_dwr
txt_ida = cmd_ida_a - cmd_ida
txt_idr = cmd_idr_a - cmd_idr
txt_noa = cmd_noa_a - cmd_noa
txt_nor = cmd_nor_a - cmd_nor
txt_pua = cmd_pua_a - cmd_pua
txt_pur = cmd_pur_a - cmd_pur
txt_rsa = cmd_rsa_a - cmd_rsa
txt_rsr = cmd_rsr_a - cmd_rsr
txt_ula = cmd_ula_a - cmd_ula
txt_ulr = cmd_ulr_a - cmd_ulr
Set itmX = ListView1.ListItems.Add(, , txt_date)
itmX.SubItems(1) = txt_parsereq
itmX.SubItems(2) = txt_flowtotal
itmX.SubItems(3) = txt_reqflow
itmX.SubItems(4) = txt_aia
itmX.SubItems(5) = txt_air
itmX.SubItems(6) = txt_cer
itmX.SubItems(7) = txt_cla
itmX.SubItems(8) = txt_clr
itmX.SubItems(9) = txt_dsa
itmX.SubItems(10) = txt_dsr
itmX.SubItems(11) = txt_dwa
itmX.SubItems(12) = txt_dwr
itmX.SubItems(13) = txt_ida
itmX.SubItems(14) = txt_idr
itmX.SubItems(15) = txt_noa
itmX.SubItems(16) = txt_nor
itmX.SubItems(17) = txt_pua
itmX.SubItems(18) = txt_pur
itmX.SubItems(19) = txt_rsa
itmX.SubItems(20) = txt_rsr
itmX.SubItems(21) = txt_ula
itmX.SubItems(22) = txt_ulr
Call clear_fourth
Call clear_five
Call clear_first
Call clear_field_name
Call clear_value
txt_sec = 0
txt_t1 = ""
txt_t2 = ""
txt_st = ""
cmd_date_time = cmd_date_time_a
cmd_ulr = cmd_ulr_a
cmd_aia = cmd_aia_a
cmd_dsa = cmd_dsa_a
cmd_rsr = cmd_rsr_a
cmd_dsr = cmd_dsr_a
cmd_noa = cmd_noa_a
cmd_pur = cmd_pur_a
cmd_dwa = cmd_dwa_a
cmd_clr = cmd_clr_a
cmd_cla = cmd_cla_a
cmd_nor = cmd_nor_a
cmd_pua = cmd_pua_a
cmd_totalparsedreq = cmd_totalparsedreq_a
cmd_rsa = cmd_rsa_a
cmd_air = cmd_air_a
cmd_ida = cmd_ida_a
cmd_ula = cmd_ula_a
cmd_cer = cmd_cer_a
cmd_flow_total = cmd_flow_total_a
cmd_idr = cmd_idr_a
cmd_dwr = cmd_dwr_a
cmd_req_flow = cmd_req_flow_a
Call clear_second
End If
to add a msflexgrid control to your form you first have to add the component which you can do in the menu.
In the project menu click on components and in there check the microsoft flexGrid control
Then have a look at the following test project:
'1 form with:
' MSFlexGrid: name=MSFlexGrid1
' Command button: name=Command1
Option Explicit
Private Sub Command1_Click()
Static lngMode As Long
'process the right modes
Select Case lngMode
Case 0
FillHorizontal
Case 1
FillVertical
Case 2
FillData
End Select
'set next mode
lngMode = (lngMode + 1) Mod 3
End Sub
Private Sub Form_Load()
With MSFlexGrid1
.FixedRows = 0
.FixedCols = 0
.Rows = 7
.Cols = 12
End With 'MSFlexGrid1
End Sub
Private Sub Form_Resize()
Dim sngWidth As Single, sngHeight As Single
Dim sngCmdHeight As Single, sngGrdHeight As Single
sngWidth = ScaleWidth
sngHeight = ScaleHeight
sngCmdHeight = 495
sngGrdHeight = sngHeight - sngCmdHeight
MSFlexGrid1.Move 0, 0, sngWidth, sngGrdHeight
Command1.Move 0, sngGrdHeight, sngWidth, sngCmdHeight
End Sub
Private Sub FillHorizontal()
Dim lngRow As Long, lngCol As Long
With MSFlexGrid1
For lngCol = 0 To .Cols - 1
For lngRow = 0 To .Rows - 1
.TextMatrix(lngRow, lngCol) = CStr(lngRow * .Cols + lngCol)
Next lngRow
Next lngCol
End With 'MSFlexGrid1
End Sub
Private Sub FillVertical()
Dim lngRow As Long, lngCol As Long
With MSFlexGrid1
For lngCol = 0 To .Cols - 1
For lngRow = 0 To .Rows - 1
.TextMatrix(lngRow, lngCol) = CStr(lngCol * .Rows + lngRow)
Next lngRow
Next lngCol
End With 'MSFlexGrid1
End Sub
Private Sub FillData()
With MSFlexGrid1
.Clear
.TextMatrix(0, 0) = "Food"
.TextMatrix(0, 1) = "Drinks"
.TextMatrix(1, 0) = "Cake"
.TextMatrix(1, 1) = "Water"
.TextMatrix(2, 0) = "Cup cake"
.TextMatrix(2, 1) = "Soft drinks"
.TextMatrix(3, 0) = "Spaghetti"
.TextMatrix(3, 1) = "Orange juice"
.TextMatrix(4, 0) = "Canton"
.TextMatrix(4, 1) = "Coffee"
.TextMatrix(5, 0) = "Abodo"
.TextMatrix(5, 1) = "Tea"
End With 'MSFlexGrid1
End Sub
When you click the button it will first fill the grid horizontally, when you click the button again it will fill the grid vertically, and when you click the button again it will fill the grid with some data
Pay attention to the use of lngRow and lngCol and how it effects the horizontal of vertical filling
这篇关于如何在列表视图TRANSPOSE(移调)数据垂直的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!