本文介绍了vb.net类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我写了我的第一堂课并将其发布到这个新闻组希望 ,我可以得到一些关于它的正确和错误的反馈。 欢迎所有评论,但更感兴趣的是什么会让它变得更好。 如果我完全错过了课程的用法,请告知我。 谢谢, 托马斯 ''*************** ********************************** **************** ********************* ''******************* ****************************** ******************** ***************** ''****这个类接受一个参数。此参数作为 日期/时间**** ''****数组传递。从这个变量中,Class计算并公开了三个 **** ''****属性。 AvgTime - 阵列中每个 值之间的平均时间**** ''****。 TimeSpan - 这是 第一个**** ''****和数组中的最后日期/时间之间的时间长度。属性以分钟形式返回 和**** ''****仅限第二个值。计数 - 这是可用日期/时间的数量 组**** ''****在传递的数组中 **** ''************************************ ************* ************************************* ''**************************************** ********* ************************************* Public Class clsTime Private _AvgTime As String Private _TimeSpan As String Private _Count As整数 私有datFirst为日期 私有datLast为日期 私有intFirst为整数= 0 私有intMinute As整数= 0 私有intSecond为整数= 0 Public Sub New (ByVal aryTime()As String) _AvgTime = funAvgTime(aryTime) _TimeSpan = funTimeSpan(aryTime) _Count =第一页 结束子 #End Region #Region" Properties" Public Property AvgTime()As String Get 返回_AvgTime 结束获取 设置(ByVal值为字符串) _AvgTime = value 结束集 结束财产 公共财产TimeSpan()字符串 获取 返回_TimeSpan 结束获取 设置(ByVal值为字符串) _TimeSpan = value 结束集 结束物业 公共财产数量()为整数 获取 返回_Count 结束获取 设置(ByVal值为整数) _Count = value 结束集 结束财产 #End Region #Region" Functions" 私函数funAvgTime(ByVal aryTime()As String)As String Dim intAvTime As Integer = 0 intFirst = 0 intMinute = 0 intSecond = 0 Array.Sort(aryTime) for x As Integer = 0 to aryTime.GetUpperBound(0) If IsDate (aryTime(x))那么 intFirst + = 1 如果intFirst = 1那么 datFirst = CDate(aryTime(x)) 结束如果 datLast = CDate(aryTime(x)) 如果intFirst> 1然后 intAvTime + = DateDiff(DateInterval.Second, CDate(aryTime(x - 1)),CDate(aryTime(x))) intAvTime = System.Math.Abs​​(intAvTime) 结束如果 结束如果 下一页 如果是intFirst> 0然后 intAvTime = intAvTime / intFirst 如果intAvTime> 60然后 intMinute = intAvTime \ 60 intSecond = intAvTime Mod 60 返回CStr(intMinute)& ":" &安培; CStr(intSecond) Else 返回CStr(intAvTime)& "秒' 结束如果 否则 返回String.Empty 结束如果 结束函数 私函数funTimeSpan(ByVal aryTimeSpan()As String)As String Dim intLength As Integer = 0 intMinute = 0 intSecond = 0 如果IsDate(datLast)AndAlso IsDate(datFirst)那么 intLength = DateDiff(DateInterval.Second,datFirst,datLast) 如果intLength> 60然后 intMinute = intLength \ 60 intSecond = intLength Mod 60 返回CStr(intMinute)& ":" &安培; CStr(intSecond) Else 返回CStr(intLength)& "秒' 结束如果 否则 返回String.Empty 结束如果 结束功能 #End Region 结束课 - 发布于NewsDemon.com - 高级未经审查的新闻组服务 ------->>>>>> http://www.NewsDemon.com< ;<<<<< ------ 无限制访问,匿名帐户,未经审查的宽带访问I have written my first Class and am posting it to this newsgroup with hopesthat I can get some feedback on what is right and what is wrong with it.All comments are welcome, but more interested in what would make it better.If I have totally missed on what a class is used for please inform me.Thanks,Thomas''************************************************* *************************************''************************************************* *************************************''**** This class accepts one parameter. This parameter is passed as aDate/Time ****''**** array. From this variable the Class calculates and exposes three****''**** properties. AvgTime - which is average time between each of thevalues ****''**** in the array. TimeSpan - which is the length of time between thefirst ****''**** and last date/time in the array. Properties are returned as Minuteand ****''**** Second values only. Count - which is the number of usable Date/Timegroups ****''**** in the passed array****''************************************************* *************************************''************************************************* *************************************Public Class clsTimePrivate _AvgTime As StringPrivate _TimeSpan As StringPrivate _Count As IntegerPrivate datFirst As DatePrivate datLast As DatePrivate intFirst As Integer = 0Private intMinute As Integer = 0Private intSecond As Integer = 0#Region "Constructors"Public Sub New(ByVal aryTime() As String)_AvgTime = funAvgTime(aryTime)_TimeSpan = funTimeSpan(aryTime)_Count = intFirstEnd Sub#End Region#Region "Properties"Public Property AvgTime() As StringGetReturn _AvgTimeEnd GetSet(ByVal value As String)_AvgTime = valueEnd SetEnd PropertyPublic Property TimeSpan() As StringGetReturn _TimeSpanEnd GetSet(ByVal value As String)_TimeSpan = valueEnd SetEnd PropertyPublic Property Count() As IntegerGetReturn _CountEnd GetSet(ByVal value As Integer)_Count = valueEnd SetEnd Property#End Region#Region "Functions"Private Function funAvgTime(ByVal aryTime() As String) As StringDim intAvTime As Integer = 0intFirst = 0intMinute = 0intSecond = 0Array.Sort(aryTime)For x As Integer = 0 To aryTime.GetUpperBound(0)If IsDate(aryTime(x)) ThenintFirst += 1If intFirst = 1 ThendatFirst = CDate(aryTime(x))End IfdatLast = CDate(aryTime(x))If intFirst > 1 ThenintAvTime += DateDiff(DateInterval.Second,CDate(aryTime(x - 1)), CDate(aryTime(x)))intAvTime = System.Math.Abs(intAvTime)End IfEnd IfNextIf intFirst > 0 ThenintAvTime = intAvTime / intFirstIf intAvTime > 60 ThenintMinute = intAvTime \ 60intSecond = intAvTime Mod 60Return CStr(intMinute) & ":" & CStr(intSecond)ElseReturn CStr(intAvTime) & " seconds"End IfElseReturn String.EmptyEnd IfEnd FunctionPrivate Function funTimeSpan(ByVal aryTimeSpan() As String) As StringDim intLength As Integer = 0intMinute = 0intSecond = 0If IsDate(datLast) AndAlso IsDate(datFirst) ThenintLength = DateDiff(DateInterval.Second, datFirst, datLast)If intLength > 60 ThenintMinute = intLength \ 60intSecond = intLength Mod 60Return CStr(intMinute) & ":" & CStr(intSecond)ElseReturn CStr(intLength) & " seconds"End IfElseReturn String.EmptyEnd IfEnd Function#End RegionEnd Class--Posted via NewsDemon.com - Premium Uncensored Newsgroup Service------->>>>>>http://www.NewsDemon.com<<<<<<------Unlimited Access, Anonymous Accounts, Uncensored Broadband Access推荐答案 这篇关于vb.net类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 17:53