Option Strict Off
專注于為中小企業(yè)提供成都做網(wǎng)站、網(wǎng)站制作服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)渾源免費做網(wǎng)站提供優(yōu)質(zhì)的服務。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千余家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設實現(xiàn)規(guī)模擴充和轉變。
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
Dim j As Integer
Dim A(9) As Short
Dim D(9) As Short
Dim i As Short
Dim B As Short
Dim C As Short
Dim F As Short
Dim G As Boolean
Dim H() As Short
Dim K As Short
Dim S As String
C = 32767
For i = 1 To 10
A(i - 1) = CShort(InputBox("輸入第 " i "個數(shù)"))
If B A(i - 1) Then B = A(i - 1)
If C A(i - 1) Then C = A(i - 1)
D(i - 1) = Int(Rnd() * 100 + 0.5)
If F D(i - 1) Then F = D(i - 1)
Next i
For i = 2 To 100
For j = 2 To Int(System.Math.Sqrt(i) + 0.5)
'UPGRADE_WARNING: Couldn't resolve default property of object j. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
'UPGRADE_WARNING: Mod has a new behavior. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
If i Mod j 0 Then
G = True
Else
G = False
Exit For
End If
Next j
If G = True Then
ReDim Preserve H(K)
H(K) = i
K = K + 1
End If
Next i
S = "2;"
For i = 0 To K - 1
S = S H(i) ";"
Next i
MsgBox("最大數(shù)為:" B ";最小數(shù)為:" C)
MsgBox("最大的隨機數(shù)為:" F)
MsgBox("1--100之間共有" K + 1 "個素數(shù):" S)
End Sub
End Class
Delphi代碼如下:
procedure?TForm1.Button1Click(Sender:?TObject);
var
購物總價:Integer;
折扣:Extended;
begin
購物總價:=StrToInt(Edit1.Text);
if?購物總價250?then
begin
折扣:=0;
end
else?if?購物總價500?then
begin
折扣:=0.05;
end
else?if?購物總價1000?then
begin
折扣:=0.075;
end
else?if?購物總價2000?then
begin
折扣:=0.1;
end
{
此段的折扣是多少?
else?if?購物總價3000?then
begin
折扣:=0.05;
end
}
else?if?購物總價=3000?then
begin
折扣:=0.15;
end;
ShowMessage('您享受的折扣是:'+FloatToStr(折扣)
+'?原價:'+IntToStr(購物總價)
+'?折后總價:'+FloatToStr(購物總價*(1-折扣)));
end;
你這是vb.net的代碼,vb中不允許那么寫:
Dim
strdx()
As
String
=
{"0",
"0",
"0"}
'定義個數(shù)組,從后面的值能看的出最大下標是2,也就是strdx(0),strdx(1)和strdx(2),3個的默認值都為0
Dim
calcount1
As
String
=
"0"
'定義個字符串變量
Dim
calcount2
As
String
=
"0"
Dim
strvalue
As
Boolean
=
False
'定義strvalue為bool值,改類型變量只有true和false
2種值
If
strdx(0)
=
"0"
Then
TextBox1.Text
=
strdx(0)
"."
這是字符串連接符號,和"+"的區(qū)別是,他把左右2邊的內(nèi)容直接連接的,而"+"可能會編程運算符,例如
2
3
=
"23"
而
2
+
3
=
5
ElseIf
strvalue
=
False
Then
strdx(0)
=
strdx(0)
"0"
TextBox1.Text
=
strdx(0)
"."
strvalue
=
True
Else
strdx(0)
=
strdx(0)
"0"
TextBox1.Text
=
strdx(0)
Select
Case
calcount1
'
這里開始是分支語句
Case
"+"
TextBox1.Text
=
Str(Val(strdx(1))
+
Val(strdx(0)))
可以的,把項目的類型設成類庫,將所有的函數(shù)用Public修飾附封裝在類里面,生成dll文件。這樣別人就可以在別人項目屬性的引用頁里面添加對你的dll文件的引用,然后導入命名空間,直接使用了。
比如說,在一個項目里:
NameSpace Controller
Public Class ControlMachine
Public Sub Boot()
End Sub
Public Sub Shutdown()
End Sub
End Class
End NameSpace
進入另一個項目的項目屬性,進入引用頁,添加到那個dll文件的引用。在代碼中:
Imports Controller '加在代碼文檔的最頂端
使用:
Dim controller As New ControlMachine
controller.Boot()
controller.Shutdown()
希望你能了解,不懂再追問