Bogart gFunction.vb
Module gFunction
'其它不是常用的方法及函數 #Region " 將指定的數據格式轉換為英文格式" Public Function EnglishFormat(ByVal intNum As Double, ByVal blnMoney As Boolean) As String
On Error GoTo err
Dim strNum As String
Dim intStart As Integer
Dim strInt As String '整數位
Dim strDec As String '小數位 strNum = Trim(Str(System.Math.Round(intNum, )))
intStart = InStr(, strNum, ".")
If intStart > Then
'取出數據中的整數部分
strInt = Mid(strNum, , intStart - )
'取出數據中的小數部分
strDec = Mid(strNum, intStart + )
Else
'表如沒有小數位數
strInt = strNum
strDec = ""
End If
If blnMoney = True Then
EnglishFormat = JoinNum(strInt) & readDec1(strDec)
Else
EnglishFormat = JoinNum(strInt) & IIf(JoinNum(strInt) = "", Mid(readDec2(strDec), ), readDec2(strDec)) & " ONLY"
End If
Exit Function
err:
EnglishFormat = "ZERO"
End Function '數字轉為英文字符
Private Function changeNumber(ByVal intI As String) As String
Select Case Int(intI)
Case
changeNumber = "ZERO"
Case
changeNumber = "ONE"
Case
changeNumber = "TWO"
Case
changeNumber = "THREE"
Case
changeNumber = "FOUR"
Case
changeNumber = "FIVE"
Case
changeNumber = "SIX"
Case
changeNumber = "SEVEN"
Case
changeNumber = "EIGHT"
Case
changeNumber = "NINE"
Case
changeNumber = "TEN"
Case
changeNumber = "ELEVEN"
Case
changeNumber = "TWELVE"
Case
changeNumber = "THIRTEEN"
Case
changeNumber = "FOURTEEN"
Case
changeNumber = "FIFTEEN"
Case
changeNumber = "SIXTEEN"
Case
changeNumber = "SEVENTEEN"
Case
changeNumber = "EIGHTEEN"
Case
changeNumber = "NINETEEN"
Case
changeNumber = "TWENTY"
Case
changeNumber = "THIRTY"
Case
changeNumber = "FORTY"
Case
changeNumber = "FIFTY"
Case
changeNumber = "SIXTY"
Case
changeNumber = "SEVENTY"
Case
changeNumber = "EIGHTY"
Case
changeNumber = "NINETY"
Case
changeNumber = "HUNDRED"
End Select
End Function 'N1 讀取小數部分(普通數據格式)
Private Function readDec1(ByVal intInt As String) As String
On Error Resume Next
Dim intlen As Integer
Dim strNum As String
Dim intN As String
intlen = Len(intInt)
Dim i As Integer
If intlen = Then Exit Function
For i = To intlen
'從右至左分別將每個數字轉為英文
intN = Mid(intInt, intlen + - i, )
strNum = changeNumber(intN) & " " & strNum
Next i
'如小數部分存在則在前加上'point'
If strNum = "" Then
Return strNum
Else
Return " POINT " & strNum
End If
End Function 'N2讀取小數部分(貨幣格式)
Private Function readDec2(ByVal intInt As String) As String
On Error Resume Next Dim intlen As Integer
Dim strNum As String
Dim intG As String
Dim i As Integer
If Len(intInt) = Then
Exit Function
ElseIf Len(intInt) = Then
intInt = intInt & ""
End If
Dim intN As String
intlen = Len(intInt)
For i = To intlen
'從右至左分別將每個數字轉為英文
intN = Mid(intInt, intlen + - i, )
Select Case i
Case '個位數
If intN > Then
strNum = changeNumber(intN)
Else
strNum = ""
End If
intG = intN
Case '十位數
If intN > Then
If intN < Then
strNum = changeNumber(intN & intG)
Else
If strNum <> "" Then
strNum = changeNumber(intN & "") & "-" & strNum
Else
strNum = changeNumber(intN & "")
End If
End If
End If
End Select
Next i
If strNum = "" Then
Return strNum
Else
Return " AND " & strNum & " CENTS"
End If End Function '取給定數據的個位,十和百位
'返回的值為 n thousand
Private Function read123(ByVal intInt As String) As String
Dim intlen As Integer
Dim strNum As String
intlen = Len(intInt)
Dim i As Integer
Dim intN As String
Dim intG As String
For i = To intlen
intN = Mid(intInt, intlen + - i, )
Select Case i
Case '個位數
If intN > Then
strNum = changeNumber(intN)
Else
strNum = ""
End If
intG = intN
Case '十位數
If intN > Then
If intN < Then '因為英文數字1到19無規則
strNum = changeNumber(intN & intG)
Else
If strNum <> "" Then
strNum = changeNumber(intN & "") & "-" & strNum
Else
strNum = changeNumber(intN & "")
End If
End If
End If
Case '百位數
If intN > Then
strNum = changeNumber(intN) & " HUNDRED " & strNum
End If
End Select
Next i
read123 = strNum
End Function '取給定數據的千位,十千和百千位
'返回的值為 n thousand Private Function read456(ByVal intInt As String) As String
Dim intlen As Integer
Dim strNum As String
intlen = Len(intInt)
Dim i As Integer
Dim intN As String
Dim intG As String
For i = To intlen
intN = Mid(intInt, intlen + - i, )
Select Case i
Case '個位數
If intN > Then
strNum = changeNumber(intN)
Else
strNum = ""
End If
intG = intN
Case '十位數
If intN > Then
If intN < Then
strNum = changeNumber(intN & intG)
Else
If strNum <> "" Then
strNum = changeNumber(intN & "") & "-" & strNum
Else
strNum = changeNumber(intN & "")
End If
End If
End If
Case '百位數
If intN > Then
strNum = changeNumber(intN) & " HUNDRED " & strNum
End If
End Select
Next i
If strNum = "" Then
read456 = ""
Else
read456 = strNum & " THOUSAND "
End If
End Function '取給定數據中的一個百萬位,十個百萬位和千個百萬位
'返回的值為 n million
Private Function read789(ByVal intInt As String) As String
Dim intlen As Integer
Dim strNum As String
intlen = Len(intInt)
Dim i As Integer
Dim intN As String
Dim intG As String '存儲臨時的數據
For i = To intlen
intN = Mid(intInt, intlen + - i, )
Select Case i
Case '個位數
'表示個位數在不為0時
If intN > Then
strNum = changeNumber(intN)
Else
strNum = ""
End If
intG = intN
Case '十位數
If intN > Then
If intN < Then '表十位數為1-19間
strNum = changeNumber(intN & intG)
Else
If strNum <> "" Then
strNum = changeNumber(intN & "") & "-" & strNum
Else
strNum = changeNumber(intN & "")
End If
End If
End If
Case '百位數
If intN > Then
strNum = changeNumber(intN) & " HUNDRED " & strNum
End If
End Select
Next i
If strNum = "" Then
read789 = ""
Else
read789 = strNum & "MILLION "
End If
End Function '合閾整數部分
Private Function JoinNum(ByVal strNum As String) As String
Dim str123 As String
Dim str456 As String
Dim str789 As String
str123 = read123(strNum)
str456 = read456(strNum)
str789 = read789(strNum) If str123 <> "" And str456 <> "" Then
str456 = read456(strNum) & "AND "
End If
If str456 <> "" And str789 <> "" Then
str789 = read789(strNum) & "AND "
End If
Return (str789 & str456 & str123).Trim End Function Private Function getValidChars(ByVal strSRC As String) As String
Dim i As Integer = strSRC.IndexOf(" ")
If i > Then
Return ((strSRC & "********").Substring(, i) & "******").Substring(, ) & "~1"
Else
Return strSRC
End If
End Function
#End Region #Region " 單位轉換函數"
'單位轉換函數,返回值為轉換系數,如無法轉換則返回-1
' Example: uomconv('CM','M') = 0.01
' Usage: uomconv(fm_uom,to_uom) Public Overloads Function uomconv(ByVal var1 As String, ByVal var2 As String) As Double
If var1 = var2 Then Return
Dim var3 As Double = -
Dim rst As ADODB.Recordset
Dim m As Integer
Dim ds As New DataSet Dim da As New OleDb.OleDbDataAdapter("select frunm,tounm,mltdiv,unmcvt from pcfunmb", netConn)
da.Fill(ds)
Dim dv As New DataView(ds.Tables(), "", "frunm,tounm,mltdiv", DataViewRowState.CurrentRows)
'dv.Sort = "frunm,tounm,mltdiv"
Dim var() As Object Try
var() = var1
var() = var2
var() =
m = dv.Find(var)
If m > Then
var3 = dv(m).Item("unmcvt")
Else
var() =
m = dv.Find(var)
If m > Then
var3 = / dv(m).Item("unmcvt")
Else
var() = var2
var() = var1
var() =
m = dv.Find(var)
If m > Then
var3 = / dv(m).Item("unmcvt")
Else
var() =
m = dv.Find(var)
If m > Then
var3 = dv(m).Item("unmcvt")
End If
End If
End If
End If
dv = Nothing
ds = Nothing
Return var3 Catch ex As Exception
Return -
End Try 'Try
' rst = New ADODB.Recordset
' rst.Open("select unmcvt from pcfunmb where frunm='" + var1 + "' and tounm='" + var2 + "' and mltdiv=1 order by unmcvt", adoConn)
' If rst.RecordCount > 0 Then
' For m = 0 To rst.RecordCount - 1
' var3 = rst.Fields("unmcvt").Value
' rst.MoveNext()
' Next
' Else
' rst = Nothing
' rst = New ADODB.Recordset
' rst.Open("select 1/unmcvt as unmcvt from pcfunmb where frunm='" + var1 + "' and tounm='" + var2 + "' and mltdiv = 2 order by unmcvt", adoConn)
' If rst.RecordCount > 0 Then
' For m = 0 To rst.RecordCount - 1
' var3 = rst.Fields("unmcvt").Value
' rst.MoveNext()
' Next
' Else
' rst = Nothing
' rst = New ADODB.Recordset
' rst.Open("select 1/unmcvt as unmcvt from pcfunmb where frunm='" + var2 + "' and tounm='" + var1 + "' and mltdiv = 1 order by unmcvt", adoConn)
' If rst.RecordCount > 0 Then
' For m = 0 To rst.RecordCount - 1
' var3 = rst.Fields("unmcvt").Value
' rst.MoveNext()
' Next
' Else
' rst = Nothing
' rst = New ADODB.Recordset
' rst.Open("select unmcvt as unmcvt from pcfunmb where frunm='" + var2 + "' and tounm='" + var1 + "' and mltdiv = 2 order by unmcvt", adoConn)
' If rst.RecordCount > 0 Then
' For m = 0 To rst.RecordCount - 1
' var3 = rst.Fields("unmcvt").Value
' rst.MoveNext()
' Next
' End If
' End If
' End If
' End If
' rst = Nothing
' Return var3
'Catch ex As Exception
' rst = Nothing
' Return -1
'End Try End Function '單位轉換函數,返回值為轉換系數,如無法轉換則返回-1
' Example2: uomconv('M','LB','CM','GSM') = 0.01
' Usage: uomconv(fm_uom,to_uom,std width,weight)
' M, LB/KG, CM, GSM Public Overloads Function uomconv(ByVal var1 As String, ByVal var2 As String, ByVal var3 As String, ByVal var4 As String) As Double
If var1 = var2 Then Return Dim v1, v2, v3, v4 As Double
v1 =
v2 =
v3 =
v4 = Dim rst As ADODB.Recordset
Dim m As Integer If var1 <> "M" Then
v1 = uomconv(var1, "M")
If v1 < Then Return -
End If If var2 <> "LB" Or var2 <> "KG" Then
v2 = uomconv(var2, "KG")
If v2 < Then
v2 = uomconv(var2, "LB")
If v2 < Then
Return -
Else
v2 = v2 * uomconv("LB", "KG") * uomconv("KG", "GM")
End If
Else
v2 = v2 * uomconv("KG", "GM")
End If
Else
If var2 = "LB" Then
v2 = uomconv("LB", "KG") * uomconv("KG", "GM")
ElseIf var2 = "KG" Then
v2 = uomconv("KG", "GM")
End If
End If
If v2 < Then Return - v3 = uomconv(var3, "M")
If v3 < Then Return - v4 = uomconv(var4, "GSM")
If v4 < Then Return -
Return (v1 * v3 * v4 / v2)
End Function Public Function GetInvQty(ByVal RMCode As String, ByVal Type As String, ByVal UOM As String, ByVal PurQty As Double, Optional ByVal DefaultValue As Double = ) As Double
Try
Dim InvUom As String = gData.selectValue(" select a.unm from phfrmt a where a.sug='" & Trim(Rmcode) & "'", adoConn)
Dim PurQty1 As Double = Val(PurQty)
If (Trim(UOM) = "LB" Or Trim(UOM) = "KG") And (InvUom <> "LB" And InvUom <> "KG") Then
Dim weight As Double = gData.selectValue("select WEIGHT from PHFRMTP where sug='" & Trim(Rmcode) & "' and ovy='" & Trim(Type) & "'", adoConn, ) Dim UOM1 As String = gData.selectValue("select WIDUNM from PHFRMTP where sug='" & Trim(Rmcode) & "' and ovy='" & Trim(Type) & "'", adoConn, ) Dim STDWID As Double = gData.selectValue("select STDWID from PHFRMTP where sug='" & Trim(Rmcode) & "' and ovy='" & Trim(Type) & "'", adoConn, ) If Trim(UOM) = "LB" Then
If UOM1 = "CM" Then
PurQty1 = * Val(PurQty1) / (Val(weight) * Val(STDWID))
Else
If UOM1 = "MM" Then
PurQty1 = * Val(PurQty1) / (Val(weight) * Val(STDWID))
Else
PurQty1 =
End If
End If
Else
If UOM1 = "CM" Then
PurQty1 = * Val(PurQty1) / (Val(weight) * Val(STDWID))
Else
If UOM1 = "MM" Then
PurQty1 = * Val(PurQty1) / (Val(weight) * Val(STDWID))
Else
PurQty1 =
End If
End If
End If
Else
Dim unmRate As Double = gData.selectValue("select unmcvt from pcfunmb where frunm='" & Trim(UOM) & "' and tounm='" & Trim(InvUom) & "'", adoConn, )
PurQty1 = PurQty1 * Val(unmRate)
End If Return Format(PurQty1, "0.0000")
Catch ex As Exception
Return DefaultValue
Exit Function
End Try
End Function Public Function GetPurQty(ByVal Sug As String, ByVal OVY As String, ByVal PurUnit As String, ByVal InvUnit As String, ByVal InvQty As Double) As Double
Dim PurQty1 As Double = Val(InvQty)
If PurUnit.Trim.ToUpper() = InvUnit.Trim.ToUpper() Then
Return Format(PurQty1, "0.000")
Exit Function
End If If (Trim(PurUnit) = "LB" Or Trim(PurUnit) = "KG") And (Trim(InvUnit) <> "LB" And Trim(InvUnit) <> "KG") Then
Dim weight As Double = CDbl(gData.SelectValue("select WEIGHT from PHFRMTP where sug='" & Trim(Sug) & "' and ovy='" & Trim(OVY) & "'", netConn, ""))
Dim UOM1 As String = gData.SelectValue("select WIDUNM from PHFRMTP where sug='" & Trim(Sug) & "' and ovy='" & Trim(OVY) & "'", netConn, "")
Dim STDWID As Double = CDbl(gData.SelectValue("select STDWID from PHFRMTP where sug='" & Trim(Sug) & "' and ovy='" & Trim(OVY) & "'", netConn, "")) If Trim(PurUnit) = "LB" Then
If UOM1 = "CM" Then
PurQty1 = (Val(PurQty1) * (Val(weight) * Val(STDWID))) /
Else
If UOM1 = "MM" Then
PurQty1 = (Val(PurQty1) * (Val(weight) * Val(STDWID))) /
Else
PurQty1 =
End If
End If
Else
If UOM1 = "CM" Then
PurQty1 = Val(PurQty1) * (Val(weight) * Val(STDWID)) * 0.00001
Else
If UOM1 = "MM" Then
PurQty1 = 0.000001 * Val(PurQty1) * (Val(weight) * Val(STDWID))
Else
PurQty1 =
End If
End If
End If
Else
Dim dt As DataTable = gData.GetDataTable("select FRUNM, TOUNM, UNMCVT, MLTDIV from PCFUNMB where FRUNM='" & InvUnit.Trim() & "' and TOUNM='" & PurUnit.Trim() & "'", netConn)
If dt.Rows.Count = Then
Dim rUnit As DataRow = dt.Rows()
If CStr(rUnit("MLTDIV")) = "" Then
PurQty1 = PurQty1 * rUnit("UNMCVT")
Else
If rUnit("UNMCVT") <> Then
PurQty1 = PurQty1 / rUnit("UNMCVT")
Else
PurQty1 =
End If
End If
Else
PurQty1 =
End If
End If
Return Format(PurQty1, "0.000")
End Function #End Region #Region "月份轉換,英文簡寫式"
Public Function MonthEnglishFormat(ByVal M As Int16) As String
Dim StrM As String
Select Case M
Case
StrM = "JAN"
Case
StrM = "FEB"
Case
StrM = "MAR"
Case
StrM = "APR"
Case
StrM = "MAY"
Case
StrM = "JUN"
Case
StrM = "JUL"
Case
StrM = "AUG"
Case
StrM = "SEP"
Case
StrM = "OCT"
Case
StrM = "NOV"
Case
StrM = "DEC"
Case Else
StrM = "ERROR"
End Select
Return StrM
End Function
#End Region End Module
Bogart gFunction.vb的更多相关文章
- Bogart BogartPublic.vb
Imports System.Data.SqlClient Imports System.Data #Region "IBogartToolbar,請勿隨便更改" Interfac ...
- Bogart SysPwd.vb
Module syspwd Public Const STR_MASK = "MyFunction" '加密用字串 '預定義密碼長度 Public GintCheckPwd As ...
- Bogart gSub.vb
'--------------Job No 0900408 -------------- '--DIM PART ONE ONLINE Update Order Qty '''主要新加過程名 Refr ...
- Bogart gData.vb
Imports System Imports System.Data Imports System.Data.OleDb Imports Microsoft.VisualBasic Imports S ...
- Bogart BogartAutoCode.vb
Imports System.Data.SqlClient Imports System.Data Public Class BogartAutoCodeDataBase Private Conn A ...
- Bogart gGrid.vb
Namespace BogartMis.Cls Public Class gGrid '設定表格控的列標題的別名 '說明:strItem字符串的格式為"01,02,03,04,05" ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- VB.NET设置控件和窗体的显示级别
前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...
- 用VB脚本批到导入字段到PowerDesigner
在PowerDesigner使用脚本批量导入excel中记录的表结构信息,由于需要通过powerdesigner逆向工程创建一些sybase IQ的表,由于是接口数据,只有excel表,手动导入太耗时 ...
随机推荐
- Qemu编译qemu-system-arm
/********************************************************************************* * Qemu编译qemu-syst ...
- BZOJ4872: [Shoi2017]分手是祝愿【概率期望DP】【思维好题】
Description Zeit und Raum trennen dich und mich. 时空将你我分开.B 君在玩一个游戏,这个游戏由 n 个灯和 n 个开关组成,给定这 n 个灯的初始状态 ...
- hdu2084 数塔 DP
数字三角形,DP裸题 #include<stdio.h> #include<string.h> #define max(a,b) (a)>(b)?a:b ][],dp[] ...
- mybatis映射文件mapper.xml的写法(collections...)
转自:https://blog.csdn.net/two_people/article/details/51759881 在学习mybatis的时候我们通常会在映射文件这样写: <?xml ve ...
- day7 python学习
今日内容# 枚举 此代码可以用于对有一定值的列表进行按带序列号的方式打印出来 lis=['手机','电脑','潜艇','手表'] for index,i in enumerate(lis,1): pr ...
- c2java Greedy 之任务调度
近期调试一个javaproject的时候,我遇到不是期望的输出结果时.是这么干的: A1凝视掉抛出的异常: A2加打印对照异常输入和正常输入. A3进一步加打印缩小范围. 事实上仅仅需:B1静下心来细 ...
- Oracle RAC 归档 与 非归档 切换
Oracle 的生产库都是启动在归档模式下,RAC下归档非归档的切换和单实例也是一样的,都是在MOUNT模式下执行ALTER DATABASE ARCHIVELOG/NOARCHIVELOG;命令. ...
- webpack 遇到报错情况及解决
webpack2 报错:optimize.OccurenceOrderPlugin is not a function. 原因:上个版本拼写错误,少写了一个字母r,新版本修正过来了.要写成这样:Occ ...
- MapReduce-线性回归
线性回归有是三个值很重要: 1. 斜率 2. 截距:x和y轴的交点值: 3. 显著性:数据偏离线性的程度,用以判断数据可以用线性表示的程度:拟合度 apache.commons.math3里面有一 ...
- 【python】实例-创建文件并通过键盘输入字符
import os lnend=os.linesep ##windows行结束符号是“\r\n” FileName=raw_input("please input filename:&quo ...