| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 469 人关注过本帖, 1 人收藏
标题:一个关于资料排版的问题
只看楼主 加入收藏
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
结帖率:97.66%
收藏(1)
 问题点数:0 回复次数:1 
一个关于资料排版的问题
这是资料从结构体经处理转存结果到暂存阵列中的一段代码:
程序代码:
Public Function ToArray(FlowCount As Integer, SubTestCount As Integer, PinNum As Integer, PinName As String, PinMin As String, PinMax As String, PinMeas As String, PinUnit As String, SiteCount As Integer, TestItemType As String) As Boolean
Dim AA As Integer, BB As Integer, CC As Integer, DD As Integer, EE As Integer
Dim FB As String, FC As String, FD As String
        
On Error GoTo ErrorHandling
    
    AA = Len(PinName)
    
    If Val(PinMin) <> 0 Then
        FB = Format(PinMin, "000.0000"): BB = Len(CStr(FB))
    Else
        BB = Len(PinMin)
    End If
    
    If Val(PinMax) <> 0 Then
        FC = Format(PinMax, "000.0000"): CC = Len(CStr(FC))
    Else
        CC = Len(PinMax)
    End If
    
    If Val(PinMeas) <> 0 Then
        FD = Format(PinMeas, "000.0000"): DD = Len(CStr(FD))
    Else
        DD = Len(PinMeas)
    End If
    
    EE = Len(PinUnit)

    OutPutData(SiteCount, OutPutDataCount) = Format(FlowCount, "000") & "." & _
                                             Format(SubTestCount, "00") & "." & _
                                             Format(PinNum, "00") & Space(5) & _
                                             PinName & Space(20 - AA) & _
                                             PinMin & Space(20 - BB) & _
                                             PinMax & Space(20 - CC) & _
                                             PinMeas & Space(20 - DD) & _
                                             PinUnit & Space(10 - EE) & _
                                             Format(SiteCount, "00") & Space(5) & _
                                             TestItemType
                                             
                                             '.Site(SiteCount).Pin(.Site(SiteCount).PinNum).PinResult
    MyDoEvents

Exit Function

ErrorHandling:
    If LogCount > UBound(LogFileNameArray) Then LogCount = UBound(LogFileNameArray)
    Call ErrorWriteBuff(LogFileNameArray(LogCount), lines, "ItemProcess", Err.Number, Err.Description, "系统讯息")
    Resume Next
End Function


想问问VB依班都是怎做排版的工作?怎排都不整齐一测之下才发现~VB中英文大写和小写和数字​​虽然都是一个字~但是宽度完全不一样~资料一Output后全都乱掉~
这样一整排下来怎做定位~英文大小写和数字​​每个字宽都不一样~那要怎搞?

以下是示例: TextBox
程序代码:
Option Explicit

Private Sub Form_Load()
Dim a As String * 20, b As String * 20, c As String * 20, d As String * 20, e As String * 20
Dim aa As String * 20, bb As String * 20, cc As String * 20, dd As String * 20, ee As String * 20

    a = "AAAAA": b = "bbbb": c = "cccccccc": d = "A": e = "AAAAAAAAA"
    aa = "11111": bb = "4444": cc = "30000002": dd = "1": ee = "13AAddsd2"
    
    Text1.Text = a & b & c & d & e & vbCrLf _
                & aa & bb & cc & dd & ee & vbCrLf
                
    a = "Aa12D": b = "ADFb": c = "ccA12ccc": d = "A": e = "AA1"
    aa = "11sdf": bb = "444d": cc = "300asd00": dd = "1": ee = "13AA"
    
    Text1.Text = Text1.Text & a & b & c & d & e & vbCrLf _
                & aa & bb & cc & dd & ee

End Sub
搜索更多相关主题的帖子: 结构体 
2011-04-16 21:47
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1820
专家分:3681
注 册:2011-3-24
收藏
得分:0 
解决了~这样就行了~至于来源资料事先用格式转换成字串即可~
程序代码:
Dim AA As String * 20, BB As String * 20, CC As String * 20, DD As String * 20, EE As String * 20, FF As String * 20, GG As String * 20

On Error GoTo ErrorHandling

    AA = PinName
    BB = PinMin
    CC = PinMax
    DD = PinMeas
    EE = PinUnit
    FF = SiteCount
    GG = TestItemType

    OutPutData(SiteCount, OutPutDataCount) = Format(FlowCount, "000") & "." & _
                                             Format(SubTestCount, "00") & "." & _
                                             Format(PinNum, "00") & Space(5) & _
                                             AA & _
                                             BB & _
                                             CC & _
                                             DD & _
                                             EE & _
                                             FF & _
                                             GG
    MyDoEvents

Exit Function

ErrorHandling:
    If LogCount > UBound(LogFileNameArray) Then LogCount = UBound(LogFileNameArray)
    Call ErrorWriteBuff(LogFileNameArray(LogCount), lines, "ItemProcess", Err.Number, Err.Description, "系統訊息")
    Resume Next
End Function
收到的鲜花
  • Artless2011-04-17 23:57 送鲜花  5朵   附言:原创内容

不要選我當版主
2011-04-16 22:37
快速回复:一个关于资料排版的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030692 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved