何必這么麻煩呢...
創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括蓮都網(wǎng)站建設(shè)、蓮都網(wǎng)站制作、蓮都網(wǎng)頁(yè)制作以及蓮都網(wǎng)絡(luò)營(yíng)銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,蓮都網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到蓮都省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
問題一(判斷回文數(shù)):
如下代碼:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim input As Integer = Val(TextBox1.Text)
If IsHui(input) Then
ListBox1.Items.Add("★" TextBox1.Text)
Else
ListBox1.Items.Add(TextBox1.Text)
End If
End Sub
Private Function IsHui(ByVal s As Integer) As Boolean
Dim input As String = s.ToString
Dim Re_input As String = StrReverse(input)
If input = Re_input Then Return True
Return False
End Function
問題二(判斷因子之和是不是質(zhì)數(shù)):
如下代碼:
'判斷是不是質(zhì)數(shù)
Private Function prime(ByVal n As Integer) As Boolean
For i = 2 To n - 1
If n Mod i = 0 Then
Return False
End If
Next
Return True
End Function
'求因子
Private Function GetFactor(ByVal s As Integer) As Integer()
Dim results(0) As Integer
Dim count As Integer = 0
For i = 1 To s
If s Mod i = 0 Then
ReDim Preserve results(count)
results(count) = i
count += 1
End If
Next
Return results
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim input As Integer = Val(TextBox2.Text)
Dim Factors() As Integer = GetFactor(input)
Dim sum As Integer
For i = 0 To Factors.Length - 1
sum += Factors(i)
Next
If prime(sum) Then
MessageBox.Show("這個(gè)數(shù)因子之和為質(zhì)數(shù)!")
Else
MessageBox.Show("這個(gè)數(shù)因子之和不是質(zhì)數(shù)!")
End If
End Sub
結(jié)果輸出上可能和題目要求有所不同,,自己變通一下,
有任何問題請(qǐng)Hi我.
您可以選擇使用CheckListBox控件。CheckListBox支持多選。
由于不清楚您用什么語(yǔ)言,所以我寫了VB.net?、C#.net
vb.net?Code
'?Determine?if?there?are?any?items?checked.
If?CheckedListBox1.CheckedItems.Count??0?Then
'?If?so,?loop?through?all?checked?items?and?print?results.
Dim?x?As?Integer
Dim?s?As?String?=?""
For?x?=?0?To?CheckedListBox1.CheckedItems.Count?-?1
s?=?s??"Checked?Item?"??(x?+?1).ToString??"?=?"??CheckedListBox1.CheckedItems(x).ToString??ControlChars.CrLf
Next?x
MessageBox.Show(s)
End?If
C#.net?Code
//?Determine?if?there?are?any?items?checked.
if(checkedListBox1.CheckedItems.Count?!=?0)
{
//?If?so,?loop?through?all?checked?items?and?print?results.
string?s?=?"";
for(int?x?=?0;?x?=?checkedListBox1.CheckedItems.Count?-?1?;?x++)
{
s?=?s?+?"Checked?Item?"?+?(x+1).ToString()?+?"?=?"?+?checkedListBox1.CheckedItems[x].ToString()?+?"\n";
}
MessageBox.Show?(s);
}
vb.net?Code
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Dim?selectstr?As?String?=?""
For?i?As?Integer?=?0?To?Me.CheckedListBox1.Items.Count?-?1
If?Me.CheckedListBox1.GetItemChecked(i)?Then
selectstr?=?Me.CheckedListBox1.Items(i).ToString
End?If
Next
MsgBox(selectstr)
End?Sub
希望能幫到您。
額 這 我倒是知道一款asp.net的=。 =叫KesionIexam它可以實(shí)現(xiàn)單選題多選題和簡(jiǎn)答題,還有填空題判斷題等等,只要按格式把試題編寫好整卷錄入就可以在前臺(tái)看到它咯!
如果需要講詳細(xì)一點(diǎn),那就加我QQ531412815
第4題,潛在的錯(cuò)誤,這里的錯(cuò)誤不是常規(guī)錯(cuò)誤,屬于那種只有在運(yùn)行是才知道的錯(cuò)誤:
Catch ex As Exception
MsgBox(ex.StackTrace)
'永遠(yuǎn)不會(huì)查找下面的錯(cuò)誤
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!")
結(jié)構(gòu)化錯(cuò)誤處理永遠(yuǎn)達(dá)不到下面這里,因?yàn)镃atch ex As Exception 已經(jīng)處理了所有錯(cuò)誤.
第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語(yǔ)言,不過這里需要該很多,
我就不用了,那么就稍微復(fù)雜一點(diǎn),使用FIND方法,不過有一點(diǎn)必須注意REF_ID必須排序,因?yàn)閿?shù)據(jù)庫(kù)中
已經(jīng)排好序了,我就不用排了。
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題:就是從一個(gè)集合中取元素輸出的問題
比較簡(jiǎn)單的辦法就是使用遞歸
以下是使用VB的方法(可以移植到VB.NET上,因?yàn)槲覍?duì)VB.NET的數(shù)組到現(xiàn)在還不太會(huì),所以就將就一下)
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是真正的遞歸函數(shù),而Combination是用來預(yù)處理字符的
全局變量:
BUSE:用來確定是否使用過這個(gè)元素
lSTR:用來保存字符元素
NCOUNT:用來限制遞歸函數(shù)的深度,換句話說,就是輸出元素組中的元素個(gè)數(shù)
實(shí)際測(cè)試成功,另外我對(duì)前三題很感興趣,希望能夠傳給我
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MessageBox.Show(ListBox1.SelectedItem.ToString)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i As Integer = 0 To 10
ListBox1.Items.Add(i.ToString)
Next
End Sub
'''''''選擇多項(xiàng)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
For i As Integer = 0 To 10
ListBox1.Items.Add(i.ToString)
Next
ListBox1.SelectionMode = SelectionMode.MultiSimple
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim item
For Each item In ListBox1.SelectedItems
MessageBox.Show(item.ToString)
Next
End Sub
asp:RadioButton ID="RadioButton1" runat="server" Text="A." GroupName="group1"/
asp:RadioButton ID="RadioButton2" runat="server" Text="B." GroupName="group1" /
asp:RadioButton ID="RadioButton3" runat="server" Text="C." GroupName="group1" /
asp:RadioButton ID="RadioButton4" runat="server" Text="D." GroupName="group1" /
div
asp:CheckBox ID="CheckBox1" runat="server" Text ="A." /
asp:CheckBox ID="CheckBox2" runat="server" Text ="B." /
asp:CheckBox ID="CheckBox3" runat="server" Text ="C." /
asp:CheckBox ID="CheckBox4" runat="server" Text ="D." /
/div
當(dāng)前名稱:vb.net多選題,都是VBNET中的數(shù)據(jù)類型的選項(xiàng)是
路徑分享:http://jinyejixie.com/article42/dsecphc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、網(wǎng)站制作、電子商務(wù)、商城網(wǎng)站、企業(yè)網(wǎng)站制作、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)