高分悬赏VB问题

2024年11月23日 06:35
有1个网友回答
网友(1):

- -我保证没有人能这么耐心的把这些都详详细细的给你编写完成。。。太多了啦。。。建议你去baidu下吧,还详细,还带源代码的,多好
1、
Public Function BIN_to_DEC(ByVal Bin As String) As Long
Dim i As Long
For i = 1 To Len(Bin)
BIN_to_DEC = BIN_to_DEC * 2 + Val(Mid(Bin, i, 1))
Next i
End Function
我一个一个帮你找- -

2、嘿嘿 也被我找到了~~适当改下函数名字,把它分成2个函数哈 要切题~~
Private Sub SetFrameState(ByRef frmParent As Form, ByRef ctlContainer As Control)
Dim o_ctlItem As Control
For Each o_ctlItem In frmParent.Controls
On Error Resume Next
With o_ctlItem
If .Container.Name = ctlContainer.Name Then
.Container.Visible = True
ctlContainer.visuble = True
ElseIf .Container.Caption = "Form1" Then
.Visible = False
End If
End With
Next

3、
Private Function F(n As Long) As Long
If n > 2 Then
F = F(n - 1) + F(n - 2)
Else
F = 1
End If
End Function

Private Sub Command1_Click()
Dim a As String
Dim i as long
Dim n as long
Dim sum as long
a = InputBox("输入斐波那契数列项数", "输入")
n = Clng(a)
Cls
For i=1 to n
sum = sum + F(i)
Next

Print "斐波那契数列前";Cstr(n);"项和:";sum
End Sub

4、baidu真好用~~~

Private Sub Command1_Click()
Dim suiji#(10)
shuru = InputBox$("输入", "随机")
For ii = 0 To 10
suiji(ii) = Int(100 * Rnd)
Next ii
For ii = 0 To 10
If Val(shuru) = suiji(ii) Then
MsgBox ("在")
Exit For
Else
End If
Next ii
End Sub

5、最后一个网上没有,自己写。。

Private Sub Form_Click()
Dim N As Integer, A() As Integer, Avg As Integer, intMid As Double
N = 10
ReDim A(1 To N) As Integer
Randomize
For i = 1 To N
A(i) = Int(Rnd * 90) + 10
Avg = Avg + A(i)
Next
'求中值
If N Mod 2 = 0 Then
intMid = (A(i / 2 - 1) + A(i / 2)) / 2
Else
intMid = A((i - 1) / 2)
End If

Print "平均值为:" & Avg / N
Print "中值为:" & intMid
End Sub