网站建设资讯

NEWS

网站建设资讯

vb.net多选题,都是VBNET中的数据类型的选项是

2个vb.net问题(恳请各位高手解答),不胜感激!

何必这么麻烦呢...

创新互联服务项目包括莲都网站建设、莲都网站制作、莲都网页制作以及莲都网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,莲都网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到莲都省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

问题一(判断回文数):

如下代码:

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

问题二(判断因子之和是不是质数):

如下代码:

'判断是不是质数

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("这个数因子之和为质数!")

Else

MessageBox.Show("这个数因子之和不是质数!")

End If

End Sub

结果输出上可能和题目要求有所不同,,自己变通一下,

有任何问题请Hi我.

.net中怎么实现下拉框多选,然后获取选中的值

您可以选择使用CheckListBox控件。CheckListBox支持多选。

由于不清楚您用什么语言,所以我写了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

希望能帮到您。

急急急!简单的在线考试系统,可以包括若干道单选题、多选题和简答题,怎么做哦???(vb.net实现)

额 这 我倒是知道一款asp.net的=。 =叫KesionIexam它可以实现单选题多选题和简答题,还有填空题判断题等等,只要按格式把试题编写好整卷录入就可以在前台看到它咯!

vb.net面试题,请大家帮忙,谢谢。

如果需要讲详细一点,那就加我QQ531412815

第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:用来限制递归函数的深度,换句话说,就是输出元素组中的元素个数

实际测试成功,另外我对前三题很感兴趣,希望能够传给我

vb.net中控件ListBox的多项选择与输出!

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

'''''''选择多项

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

如何在vb.net中实现单选题和多选题功能?

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


网页名称:vb.net多选题,都是VBNET中的数据类型的选项是
分享链接:http://cdweb.net/article/dsecphc.html