求助]数据移动问题

txlk33 2008-09-19 01:35:31
MSHFlexGrid 中的列与列之间数据怎样替换呢?

如 A 列123 B列456 这里,要替换24。那么,结果为 A列为134, B列为 562 这样的。
...全文
119 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
txlk33 2008-09-19
  • 打赏
  • 举报
回复

啊~ 谢谢。
txlk33 2008-09-19
  • 打赏
  • 举报
回复

上面写错了, MSHFlexgrid的 ABC列中 C列的一个数移动至B列 B烈的一个数移动至 A列,A列的一个数移动至C列里。

就是这样的。 应该是数据循环,不是替换了
jhone99 2008-09-19
  • 打赏
  • 举报
回复
Private Sub Form_Load()
With MSFlexGrid1
.Row = 1
.Col = 1
.Text = "524312"
.Col = 2
.Text = "dfd3333"
.Col = 3
.Text = "euui33"
End With

End Sub

Private Sub Command1_Click()
Dim strA As String
Dim strB As String
Dim strC As String

Dim strR(3) As String
Dim intS(3) As Integer
Dim strT As String
Dim i As Integer
Dim j As Integer


strA = "2"
strB = "4"
strC = "d"


With MSFlexGrid1
.Row = 1

For j = 1 To 3
.Col = j
intS(j - 1) = Len(.Text)
Next j

For j = 1 To 3
.Col = j
For i = 1 To Len(.Text)
If Mid(.Text, i, 1) = strA Then
.Text = Left(.Text, i - 1) & Mid(.Text, i + 1, Len(.Text))
strR(j - 1) = strA
Exit For
ElseIf Mid(.Text, i, 1) = strB Then
.Text = Left(.Text, i - 1) & Mid(.Text, i + 1, Len(.Text))
strR(j - 1) = strB
Exit For
ElseIf Mid(.Text, i, 1) = strC Then
.Text = Left(.Text, i - 1) & Mid(.Text, i + 1, Len(.Text))
strR(j - 1) = strC
Exit For
End If
Next i
Next j

For j = 1 To 3
.Col = j
.Text = .Text & strR(IIf(j = 3, 0, j))
Next j


For j = 3 To 1 Step -1
.Col = j
If Len(.Text) > intS(j - 1) Then
strT = Left(.Text, Len(.Text) - intS(j - 1))
.Text = Mid(.Text, Len(strT) + 1, Len(.Text))
.Col = IIf(j = 1, 3, j - 1)
.Text = .Text & strT
End If
Next j
End With

End Sub
txlk33 2008-09-19
  • 打赏
  • 举报
回复

又没有对这个方面精通的高手呢

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧