VSFlexGrid的用法--VB6 联系客服

发布时间 : 星期日 文章VSFlexGrid的用法--VB6更新完毕开始阅读d3307edcb9f3f90f76c61b3c

'SendKeys \ Else

VSG1.Editable = flexEDKbd SendKeys \ End If End Sub 或:

Private Sub VSG1_RowColChange() If VSG1.Col = 1 or VSG1.Col = 3 Then SendKeys \Else

SendKeys \End If End Sub 或:

Private Sub VSG1_RowColChange() If VSG1.Col = 1 or VSG1.Col = 3 Then VSG1.Editable = flexEDNone Else

VSG1.Editable = flexEDKbd VSG1.EditCell '自动选择单元内容

VSG1.EditSelStart = 0[选到最前]|1[选到指定]|Len(VSG1.Text)[选到最后] End If End Sub

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ '对齐方式(-1标示所有)

.ColAlignment(-1) = flexAlignLeftCenter|flexAlignCenterCenter|flexAlignRightCenter

示例1:(最后一行的第3列靠右对齐) VSG1.Select VSG1.Rows - 1, 2

VSG1.CellAlignment = flexAlignRightCenter 示例2:

VSG1.Row = VSG1.Rows - 1: VSG1.Col = 1 VSG1.CellAlignment = flexAlignRightCenter 示例3:

VSG1.Cell(flexcpAlignment, VSG1.Rows - 1, 1, VSG1.Rows - 1, 3) = flexAlignRightCenter

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 本对象拖放:

Private Sub VSG1_MouseDown(Button As Integer, _ Shift As Integer, X As Single, Y As Single) VSG1.Drag

VSG1.DragIcon = LoadPicture(\VSG1.DragRow VSG1.RowSel

End Sub 或从其它对象拖:

Private Sub VSG2_MouseDown(Button As Integer, _ Shift As Integer, X As Single, Y As Single) VSG2.OLEDrag

VSG1.OLEDropMode = flexOLEDropAutomatic End Sub

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Public Sub VSGridCount(Optional SelRow As Long, Optional SelCol As Long) Dim X As Long, i As Long Dim Hj1, Hj2, Hj3 As String

Const A1 = -922337203685477#, A2 = 922337203685477# On Error GoTo ErrTransact With frmFG.VSG1 X = .Rows - 1

.MergeCells = flexMergeFree .MergeRow(X) = True

.Cell(flexcpText, X, 0, X, 1) = \合 计\ If .Rows = 3 Then .TextMatrix(X, 0) = 0

.Cell(flexcpText, X, 2, X, 14) = \ .Cell(flexcpText, X, 16, X, 17) = \¥0.00\ Exit Sub End If

'Hj1 = Val(.Aggregate(flexSTSum, 2, 2, X - 1, 2)) 'Hj2 = Val(.Aggregate(flexSTSum, 2, 16, X - 1, 16)) 'Hj3 = CurrencyToStr(Hj2) For i = 2 To X - 2

Hj1 = Hj1 + Val(.TextMatrix(i, 15)) If Val(.TextMatrix(i, 16)) > 0 Then

Hj2 = Hj2 + Val(.TextMatrix(i, 15)) * Val(.TextMatrix(i, 16)) End If Next i

If Hj2 <= A1 or Hj2 >= A2 Then GoTo ErrTransact End If

Hj3 = CurrencyToStr(Hj2) .TextMatrix(X, 2) = Hj1

.Cell(flexcpText, X, 3, X, 15) = IIf(Hj3 = \ .Cell(flexcpText, X, 16, X, 17) = Format(Hj2, \¥0.00\ .Cell(flexcpAlignment, X, 2, X, 14) = flexAlignLeftCenter '.Select X, 3

'.CellAlignment = flexAlignLeftCenter

If SelRow > 1 And SelCol > 0 Then .Select SelRow, SelCol

End With Exit Sub ErrTransact:

MsgBox \你输入的数字过大无法计算!请修改!!!\End Sub

------------------------------------------------ 将数字转换为大写金额的函数:

Function CurrencyToStr(ByVal Number As Currency) As String Number = Val(Trim(Number))

If Number = 0 Then CurrencyToStr = \ Dim str1Ary As Variant, str2Ary As Variant str1Ary = Split(\零 壹 贰 叁 肆 伍 陆 柒 捌 玖\

str2Ary = Split(\分 角 元 拾 佰 仟 万 拾 佰 仟 亿 拾 佰 仟 万 拾 佰\ Dim a As Long, b As Long '循环基数 Dim tmp1 As String '临时转换 Dim tmp2 As String '临时转换结果 Dim Point As Long '小数点位置

If Number <= -922337203685477# or Number >= 922337203685477# Then Exit Function End If

tmp1 = Round(Number, 2)

tmp1 = Replace(tmp1, \先去掉“-”号 Point = InStr(tmp1, \取得小数点位置 If Point = 0 Then '如果有小数点,最大佰万亿 b = Len(tmp1) + 2 '加2位小数 Else

b = Len(Left(tmp1, Point + 1)) '包括点加2位小数 End If

''先将所有数字替换为中文 For a = 9 To 0 Step -1

tmp1 = Replace(Replace(tmp1, a, str1Ary(a)), \ Next

For a = 1 To b b = b - 1

If Mid(tmp1, a, 1) <> \

If b > UBound(str2Ary) Then Exit For

tmp2 = tmp2 & Mid(tmp1, a, 1) & str2Ary(b) End If Next

If tmp2 = \ ''〓下面为非正式财务算法,可以去掉〓 For a = 1 To Len(tmp2)

tmp2 = Replace(tmp2, \零亿\亿零\ tmp2 = Replace(tmp2, \零万\万零\

tmp2 = Replace(tmp2, \零仟\零\ tmp2 = Replace(tmp2, \零佰\零\ tmp2 = Replace(tmp2, \零拾\零\ tmp2 = Replace(tmp2, \零元\元\ tmp2 = Replace(tmp2, \零零\零\ tmp2 = Replace(tmp2, \亿万\亿\ Next

''〓上面为非正式财务算法,可以去掉〓 If Point = 1 Then tmp2 = \零元\ If Number < 0 Then tmp2 = \负\ If Point = 0 Then tmp2 = tmp2 + \整\ CurrencyToStr = tmp2 End Function

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Cell 属性的使用:

Cell 的作用是给以选定区块的特定的设置值,具体值可参阅相应属性值。 语法:Cell(条件准则, Row1, Col1, Row2, Col2) = 相应准则值 其中的“条件准则”有以下准则常数,根据准则的不同而设置相应准则的值: flexcpAlignment 对齐方式 flexcpBackColor 背景色 flexcpChecked 选择框 flexcpCustomFormat 格式设置 flexcpData 日期 flexcpFloodColor 颜色 flexcpFloodPercent 背景色 flexcpFont 字体 flexcpFontBold 粗体 flexcpFontItalic 斜体 flexcpFontName 字体名 flexcpFontSize 字体大小 flexcpFontStrikethru 删除线 flexcpFontUnderline 下划线 flexcpFontWidth 字符宽 flexcpForeColor 字符色 flexcpHeight 高 flexcpLeft 左 flexcpPicture 添加图 flexcpPictureAlignment 图对齐 flexcpRefresh 刷新 flexcpSort 分类 flexcpText 字符 flexcpTextDisplay 显示字符 flexcpTextStyle 文本样式

flexcpTop 返回顶端高,同 RowPos 和 valueMatrix 属性