如果需要讲详细一点,那就加我QQ531412815
创新互联从2013年创立,是专业互联网技术服务公司,拥有项目网站设计、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元临县做网站,已为上家服务,为临县各地企业和个人服务,联系电话:028-86922220
第4题,潜在的错误,这里的错误不是常规错误,属于那种只有在运行是才知道的错误:
Catch ex As Exception
MsgBox(ex.StackTrace)
'永远不会查找下面的错误
Catch ex As ArgumentNullException
MsgBox("Input Test box cannot be null.")
Catch ex As OverflowException
MsgBox("Input Test box 2 cannot be zero!")
Catch ex As FormatException
MsgBox("Input Test box should be numeric format!")
结构化错误处理永远达不到下面这里,因为Catch ex As Exception 已经处理了所有错误.
第5题:
00123
1000 60.50
2000 60.00
3500 59.50
---- -----
6500 60.00
00124
3000 60.50
---- -----
3000 60.50
00125
2000 59.50
1000 58.00
---- -----
3000 58.75
就是按照Ref_ID 分类,有一种方法就是按照Ref_ID 分组,也就是使用SQL语言,不过这里需要该很多,
我就不用了,那么就稍微复杂一点,使用FIND方法,不过有一点必须注意REF_ID必须排序,因为数据库中
已经排好序了,我就不用排了。
Dim rst as ADODB.Recordset
dim refID as string
Rst = GetRecordset
Do While Not rst.EOF
refid=rst(0)
Console.writeline(rst.Fields("Ref_ID")
do
Console.writeline rst.Fields("Qty") vbcrlf rst.Fields("Price"))
rst.MoveNext()
loop while rst(0)=refid
Loop
第6题:就是从一个集合中取元素输出的问题
比较简单的办法就是使用递归
以下是使用VB的方法(可以移植到VB.NET上,因为我对VB.NET的数组到现在还不太会,所以就将就一下)
Dim bUse() As Boolean
Dim lStr() As String * 1
Dim nCount As Byte
-----------------------------------------------------------------------------------
Public Sub Combination(lstStr As String)
Dim i As Byte
Dim j As Byte
Dim StrLen As Byte
StrLen = Len(lstStr)
ReDim bUse(1 To StrLen) As Boolean
ReDim lStr(1 To StrLen) As String * 1
For i = 1 To StrLen
lStr(i) = Mid(lstStr, i, 1)
Next
For i = 1 To StrLen
nCount = i
GoWith StrLen, 1, 0, ""
Next
End Sub
------------------------------------------------------------------------------------
Public Sub GoWith(ECount As Byte, nStart As Byte, Deep As Byte, lastStr As String)
Dim i As Byte
If Deep = nCount Then
Debug.Print lastStr
Exit Sub
End If
For i = nStart To ECount
If Not bUse(i) Then
bUse(i) = True
GoWith ECount, i, Deep + 1, lastStr lStr(i)
bUse(i) = False
End If
Next
End Sub
--------------------------------------------------------------------------------------
Private Sub Form_Load()
Combination "wxyz"
End Sub
--------------------------------------------------------------------------------------
其中GOWITH是真正的递归函数,而Combination是用来预处理字符的
全局变量:
BUSE:用来确定是否使用过这个元素
lSTR:用来保存字符元素
NCOUNT:用来限制递归函数的深度,换句话说,就是输出元素组中的元素个数
实际测试成功,另外我对前三题很感兴趣,希望能够传给我
1.编程求1!+3!+5!+....+n! N由inputbox获取
Function Math(ByVal N As Integer) As Integer
Dim c As Integer = 1
For i = 1 To N
c *= i
Next
Return c
End Function
Dim N As String = InputBox("输入N的值.")
If N = "" Then Return
MessageBox.Show(Math(N))
2.用最简单的方法将个位数和十位数互换,一定要最简单的方法..比如31换成13.
Dim s As String = InputBox("输入一个十位数.")
If s = "" Then Return
MessageBox.Show(StrReverse(s))
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim g() As Char = a.ToCharArray
Dim MyRandom As New Random
Dim bs As String = ""
For i = 1 To 20
bs = g(MyRandom.Next(0, g.GetUpperBound(0) + 1))
Next
Dim gs() As String = (From mt As Match In Regex.Matches(bs, "[A-Z]") Select mt.Value).ToArray
System.Array.Sort(gs)
gs = (From mt As Match In Regex.Matches(Join(gs, ""), "([A-Z])\1*") Select mt.Value).ToArray
Dim g_len() As Integer
g_len = (From mt As Match In Regex.Matches(Join(gs, ""), "([A-Z])\1*") Select mt.Length).ToArray ' 使用数组元素作为计数器g_len
System.Array.Sort(g_len, gs)
Label1.Text = "出现次数最多的字母:" gs(gs.GetUpperBound(0)).Substring(0, 1) " 共出现" g_len(g_len.GetUpperBound(0)) "次" vbCrLf "没有出现的字母是:" Join(a.Split(bs.ToCharArray), "")
End Sub
End Class
文章题目:vb点虐
大题 vbnet implements
网页链接:/article12/ddejigc.html
成都网站建设公司_创新互联,为您提供小程序开发、标签优化、建站公司、静态网站、网页设计公司、搜索引擎优化
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联