Private Sub Form_Load()
Dim i As Integer
For i = 1 To 100
If (i Mod 7 = 0) Then
Combo1.AddItem i
End If
Next
End Sub
输入两个数m,n,求这两个数之间能被2整除的数,并添加到列表框中 用delphi语言.我答的呢,怎么没有了,写了好长时间呀
首先,创建一个窗体,在上面放置两个EDit控件,EDIT 只允许输入整数。
var
m, n : integer
放置一个button 一个label.
var
iMAX, iMin, i integer
begin
m := StrToint(edit1.txt)
n := StrToint(edi2.txt)
if (m >n)
{
iMax := ((m - 1) div 2) * 2
iMin := ((n + 1) div 2)* 2
}
else
{
iMax := ((n - 1) div 2) * 2
iMin := ((m + 1) div 2)* 2
}
label1.caption := '被2 整除的数有:'
for i := iMin to iMAX do
begin label1.caption := label1.caption + IntTostr(i) + ', '
i = i + 1
end
end
用delphi语言.输入两个数m,n,求这两个数之间能被2整除的数,并添加到列表框中for i := m to n do
if i mod 2 = 0 then
ListBox1.Items.Add ( IntToStr(i))
在列表框中输出100~1000之间能被37整除的数。111,148,185,
222,259,296,
333,370,
407,444,481,
518,555,592,
629,666,
703,740,777,
814,851,888,
925,962,999。
vb中 怎样使列表框1的项目添加到列表框2中Private Sub Command2_Click()
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
End Sub 全部添加
Private Sub Command1_Click() 只添加选定的
For i = 0 To List1.ListCount - 1
If List1.Selected(i) Then List2.AddItem List1.List(i)
Next
End Sub
Private Sub Form_Load()
For i = 1 To 9
List1.AddItem i
Next
End Sub
delphi 程序题 输入两个数,求这两个数之间能被K(是一个整数)整除的数,并把这些数字添加到列表框里
procedure TForm1.btnOKClick(Sender: TObject)
var
v_Index,M,N,K:Integer
begin
M := StrToIntDef(Edit1.Text,0)起始数
N := StrToIntDef(Edit2.Text,0)结束数
K := StrToIntDef(Edit3.Text, 1)K
ListBox1.Items.Clear先清空列表
for v_Index := M to N do 遍历M到N(含M和N)之间的所有整数
begin
if v_Index mod K = 0 then 能被K整除的数(即除以K余0的数)
begin
ListBox1.Items.Add(IntToStr(v_Index))
end
end
end
VB高手帮忙:用inputbox输入n值,单击mand求1到n之间能被11整除的数的和。结果添加入列表框中private sub mand1_click()
dim n as integer,i as integer,sum as integer
n=val(inputbox("input n=","data Input",11)
sum=0
for i=1 to n
if i mod 11 =0 then
sum=sum+i
end if
list1.additem n,list1.listindex+1
end sub
vb中怎样把文本框的文本添加到列表框List1.AddItem Text1,0
最后一个数字指定位置
求300到500之间能被37整除的数字的vb编程Dim a, b
Private Sub Form_Click()
b = 37
For a = 300 To 500
If a Mod b = 0 Then Print a
Next
End Sub
'取300到500之间的整数,除以37,余数为0就是整除
在python中可以使用range()函数来产生一系列数字。forwinrange(1,11):print(w),输出:1,2,3,4,5,6,7,8,9。
如果将range()作为参数传递给list()函数,那么就会将数字以列表的形式输出,num=list(range(1,11)),print(num),输出:[1,2,3,4,5,6,7,8,9,10]。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)