网站建设资讯

NEWS

网站建设资讯

vb编写net vb编写100至999的水仙花数

vb.net的编程

Option Strict Off

专注于为中小企业提供成都做网站、网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业浑源免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千余家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

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 "个数"))

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("最大数为:" B ";最小数为:" C)

MsgBox("最大的随机数为:" F)

MsgBox("1--100之间共有" K + 1 "个素数:" S)

End Sub

End Class

用VB.NET程序编写代码

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.net的代码,vb中不允许那么写:

Dim

strdx()

As

String

=

{"0",

"0",

"0"}

'定义个数组,从后面的值能看的出最大下标是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)

"."

这是字符串连接符号,和"+"的区别是,他把左右2边的内容直接连接的,而"+"可能会编程运算符,例如

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)))

如何编写VB.NET 接口程序

可以的,把项目的类型设成类库,将所有的函数用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()

希望你能了解,不懂再追问


当前题目:vb编写net vb编写100至999的水仙花数
URL地址:http://cdweb.net/article/doggcpd.html