Pls help vb code
时间:2013-11-09
来源:互联网
I don't understand what they means, can anyone help :
Public Function WritePOSvalue(ByRef iarr_Field() As String, ByVal ii_Loc As Integer, ByVal is_Value As String, _
Optional ByVal id_Date As Date, Optional ByVal in_Num As Double, Optional ByVal ii_Repect As Integer) As String
Dim fs_RtnVal As String
Dim fs_Type As String
Dim fi_Size As Integer
Dim fi_ValLen As Integer
Dim fi_Loop As Integer
Dim fi_Start As Integer
Dim fs_Format As String
Dim fs_TmpStr As String
fs_RtnVal = ""
fs_Type = iarr_Field(ii_Loc, 0)
If IsMissing(ii_Repect) Then
ii_Repect = 0
End If
Select Case fs_Type
Case "X": 'String
fi_Size = Val(iarr_Field(ii_Loc, 1))
fi_ValLen = Len(is_Value)
If fi_ValLen <= fi_Size Then
fs_RtnVal = is_Value
fs_RtnVal = Replace(fs_RtnVal, Chr(13), ":", 1, ii_Repect)
fs_RtnVal = Replace(fs_RtnVal, Chr(13), " ")
fs_RtnVal = Replace(fs_RtnVal, Chr(10), " ")
Else
fi_Loop = 1
fi_Start = 1
Do While fi_ValLen > 0 And ii_Repect > -1
fs_TmpStr = Mid(is_Value, fi_Start, 1)
'Encode the special char
Select Case fs_TmpStr
Case ":"
fs_TmpStr = "?:"
Case "'"
fs_TmpStr = "?'"
Case "?"
fs_TmpStr = "??"
End Select
If fs_TmpStr = Chr(13) Then
fs_TmpStr = ":"
ii_Repect = ii_Repect - 1
fi_Loop = 0
ElseIf fs_TmpStr = Chr(10) Then
fs_TmpStr = ""
Else
fi_Loop = fi_Loop + 1
End If
fs_RtnVal = fs_RtnVal & fs_TmpStr
fi_ValLen = fi_ValLen - 1
fi_Start = fi_Start + 1
If fi_Loop = fi_Size Then
ii_Repect = ii_Repect - 1
fi_Loop = 1
If ii_Repect > 0 Then
fs_RtnVal = fs_RtnVal & ":"
End If
End If
Loop
End If
Public Function WritePOSvalue(ByRef iarr_Field() As String, ByVal ii_Loc As Integer, ByVal is_Value As String, _
Optional ByVal id_Date As Date, Optional ByVal in_Num As Double, Optional ByVal ii_Repect As Integer) As String
Dim fs_RtnVal As String
Dim fs_Type As String
Dim fi_Size As Integer
Dim fi_ValLen As Integer
Dim fi_Loop As Integer
Dim fi_Start As Integer
Dim fs_Format As String
Dim fs_TmpStr As String
fs_RtnVal = ""
fs_Type = iarr_Field(ii_Loc, 0)
If IsMissing(ii_Repect) Then
ii_Repect = 0
End If
Select Case fs_Type
Case "X": 'String
fi_Size = Val(iarr_Field(ii_Loc, 1))
fi_ValLen = Len(is_Value)
If fi_ValLen <= fi_Size Then
fs_RtnVal = is_Value
fs_RtnVal = Replace(fs_RtnVal, Chr(13), ":", 1, ii_Repect)
fs_RtnVal = Replace(fs_RtnVal, Chr(13), " ")
fs_RtnVal = Replace(fs_RtnVal, Chr(10), " ")
Else
fi_Loop = 1
fi_Start = 1
Do While fi_ValLen > 0 And ii_Repect > -1
fs_TmpStr = Mid(is_Value, fi_Start, 1)
'Encode the special char
Select Case fs_TmpStr
Case ":"
fs_TmpStr = "?:"
Case "'"
fs_TmpStr = "?'"
Case "?"
fs_TmpStr = "??"
End Select
If fs_TmpStr = Chr(13) Then
fs_TmpStr = ":"
ii_Repect = ii_Repect - 1
fi_Loop = 0
ElseIf fs_TmpStr = Chr(10) Then
fs_TmpStr = ""
Else
fi_Loop = fi_Loop + 1
End If
fs_RtnVal = fs_RtnVal & fs_TmpStr
fi_ValLen = fi_ValLen - 1
fi_Start = fi_Start + 1
If fi_Loop = fi_Size Then
ii_Repect = ii_Repect - 1
fi_Loop = 1
If ii_Repect > 0 Then
fs_RtnVal = fs_RtnVal & ":"
End If
End If
Loop
End If
作者: wsp2 发布时间: 2013-11-09
条 code 未完,得一半,贴埋下半节再睇
作者: 鸟寑e世 发布时间: 2013-11-10
仲有,请用 code tag
作者: 鸟寑e世 发布时间: 2013-11-10
Case "D": 'Date
fs_Format = iarr_Field(ii_Loc, 1)
If IsDate(id_Date) Then
If id_Date = gdDummy Then
fs_RtnVal = ""
Else
fs_RtnVal = Format(id_Date, fs_Format)
End If
Else
fs_RtnVal = ""
End If
Case "9": 'Numeric (Integer / Floating Point)
fs_Format = iarr_Field(ii_Loc, 1)
If IsNumeric(in_Num) Then
fs_RtnVal = Format(in_Num, fs_Format)
Else
fs_RtnVal = "0"
End If
End Select
WritePOSvalue = fs_RtnVal & ":"
End Function
fs_Format = iarr_Field(ii_Loc, 1)
If IsDate(id_Date) Then
If id_Date = gdDummy Then
fs_RtnVal = ""
Else
fs_RtnVal = Format(id_Date, fs_Format)
End If
Else
fs_RtnVal = ""
End If
Case "9": 'Numeric (Integer / Floating Point)
fs_Format = iarr_Field(ii_Loc, 1)
If IsNumeric(in_Num) Then
fs_RtnVal = Format(in_Num, fs_Format)
Else
fs_RtnVal = "0"
End If
End Select
WritePOSvalue = fs_RtnVal & ":"
End Function
作者: wsp2 发布时间: 2013-11-10
略略睇过,看来系将 String is_value transform to another format based on the information of the two dimension array iarr_Field()
条 code 几有趣,系典型既反面教材
条 code 几有趣,系典型既反面教材
作者: 鸟寑e世 发布时间: 2013-11-10
即系点, 我想知段 code 的作用?
By the way, what do u means by 反面教材?
By the way, what do u means by 反面教材?
作者: wsp2 发布时间: 2013-11-10
引用:原帖由 wsp2 於 2013-8-18 01:59 AM 发表
即系点, 我想知段 code 的作用?
By the way, what do u means by 反面教材?
所谓反面教材,就系指条 code d variable 同 funciton 名描述性好低,就算比你了解晒个 funciton 既 logic,你都唔会知条 code 背后既真正目的。举个例
即系点, 我想知段 code 的作用?
By the way, what do u means by 反面教材?
复制内容到剪贴板代码:double foo(double a, double b) {
return( (a*b) / 2));
}
你可以估到上面条 code 真正意图吗?? 如果写成咁就一目了然
return( (a*b) / 2));
}
复制内容到剪贴板代码:double cal_triangle_area(double tri_height, double tri_base) {
return( (tri_height * tri_base) / 2);
}
讲返你条 code, 主要系对 parameter is_Value 做一d 处理,但问题系,is_Value 系一个咩野 value 呢? 系个 function 入面根本估唔到,仲有个 function 名,WritePOSValue,除左 POS 知 道可能系 Point of Sales 之外,WritePOSValue 到底系咩野意思呢? 成条 code 只系做转换,冇 write 既动作,到底 write 去边? 抑或只系 write 落去 return value 度呢,我谂只有写个个人至知。return( (tri_height * tri_base) / 2);
}
仲有唔该你问问题之前交待一下问题既背景资料,就咁贴条 code 出来,就算呢度d 高手想答你都答你唔到
作者: 鸟寑e世 发布时间: 2013-11-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28