求幫忙編寫VB if then程式

2022-01-13 10:10:17 字數 5892 閱讀 5936

1樓:製作問題專家

private sub btnstart_click()

'按要求寫了if-then語句,不過個人認為select-case比較適合這個。

if me.txbplanet.text = "jupiter" then

'format格式化結果,保留2位小數。

me.lbltime.caption = "光從太陽到金星的時間為:" & format((1800000000 / 186282) / 60, "##.##") & "分鐘"

elseif me.txbplanet.text = "saturn" then

me.lbltime.caption = "光從太陽到木星的時間為:" & format((480000000 / 186282) / 60, "##.##") & "分鐘"

elseif me.txbplanet.text = "venus" then

me.lbltime.caption = "光從太陽到土星的時間為:" & format((900000000 / 186282) / 60, "##.##") & "分鐘"

elseif me.txbplanet.text = "neptune" then

me.lbltime.caption = "光從太陽到海王星的時間為:

" & format((2800000000# / 186282) / 60, "##.##") & "分鐘"

else

msgbox "請輸入正確資訊!", 64, "提示"

end if

end sub

希望能幫到你。

vb中用if then 語句編寫求一元二次方程的**

2樓:聽不清啊

private sub command1_click()a = val(text1)

b = val(text2)

c = val(text3)

d = b * b - 4 * a * cif b >= 0 then

x1 = (-b + sqr(d)) / (2 * a)x2 = (-b - sqr(d)) / (2 * a)text4 = x1

text5 = x2

else

msgbox "該方程無實數根!"

end if

end sub

求大神幫忙設計個vb的程式

3樓:匿名使用者

dim a as integer                      ''定義a

a= val(inputbox("請輸入乙個數") )      ''把輸入對話方塊的字元賦值給a,用val轉換

if a mod 5 = 0 or a mod 8 = 0 then   ''vb取整運算用mod,如a能被5or8取整,輸出

print"yes"

else                                 ''如果a不能被5or8取整,則輸出

print"no"

end if

求好心人幫忙做做vb程式,不能用迴圈,用if case之類的

4樓:匿名使用者

3\dim s as string

s=inputbox("請輸入乙個字元")if asc(s) > asc("a") and asc(s) < asc("z") then

print s & " 是小寫字母"

else

if if asc(s) > asc("a") and asc(s) < asc("z") then

print s & " 是小寫字母"

else

if if asc(s) > asc("0") and asc(s) < asc("9") then

print s & " 是數字"

else

print s & " 是其他字元"

end if

end if

end if

5樓:流星雨_心雨

第三個:

if text1.text=a or b or c or d……or z then '就是從a or 到z 我就略寫了

msgbox"小寫字母"

end if

if text1.text=0 or 1 or 2 or 3……or 9 then '就是從0 or 到9我就略寫了

msgbox"數字"

end if

if text1.text=a or b or c or d……or z then '就是從a or 到z 我就略寫了

msgbox"大寫字母"

end if

else

msgbox"其他字元"

end if

請高手幫我編寫乙個vb程式,謝謝 100

6樓:風雪劍無痕

private sub form_keydown(keycode as integer, shift as integer)

if keycode = vbkeyspace thensendkeys "w"

end if

end sub

7樓:

想做壞事吧,搜尋「鉤子」 hook

8樓:匿名使用者

我會易語言的。。。vb的不會。。

幫忙用vb編寫乙個程式

9樓:匿名使用者

**如下:

option explicit

dim x(), j as integer

private sub cmd_get_click()

dim y=int(rnd * 7)

redim x(1 to y )

rep:

for j = 1 to y

x(j) = int(rnd * 100)

next j

if x(1) = x(2) or x(1) = x(3) or x(1) = x(4) _

or x(1) = x(5) or x(1) = x(6) or x(1) = x(7) _

or x(2) = x(3) or x(2) = x(4) or x(2) = x(5) _

or x(2) = x(6) or x(2) = x(7) or x(3) = x(4) _

or x(3) = x(5) or x(3) = x(6) or x(3) = x(7) _

or x(4) = x(5) or x(4) = x(6) or x(4) = x(7) _

or x(5) = x(6) or x(5) = x(7) or x(6) = x(7) then

goto rep

else

for j = 1 to y

print x(j);

next j

print

end if

end sub

點選一次cmd_get為按鈕控制項,每按一次即產生一組隨機數。

大蝦們!!幫忙用vb編寫乙個簡單的程式!!

10樓:石沖口

你的三道題我都解決了

dim num1 as integer

dim ans as string

num1 = inputbox("請輸入乙個數:", "輸入資料")ans = num1 mod 2

if ans = 0 then

print num1 & "是偶數"

else

print num1 & "是奇數"

end if

11樓:

設這個整數是a

if int(a/2)=a then

'a是整數

else

'a是奇數

end if

12樓:流郎亦楓

dim input_num as integerdim reply_num as stringinput_num = inputbox("請輸入:", "輸入框", "")

reply = input_num mod (2)if reply = 0 then

print "是偶數"

else

print "是奇數"

end if

測試通過

13樓:

private sub command1_click()n = int(inputbox(""))if n mod 2 = 0 then

msgbox cstr(n) & " 是偶數"

else

msgbox cstr(n) & " 是奇數"

end if

end sub

14樓:匿名使用者

你要的程式**來了,並且已經自己驗證ok!!!

private sub command1_click()dim num as integer

num = inputbox("請輸入乙個整數:", "輸入提示")if num mod 2 = 0 thenmsgbox ""& num & " 是偶數!"

else

msgbox ""& num & " 是奇數!"

end if

end sub

我也是vb愛好者,以後互相學習學習!!!

求幫忙編乙個簡單的程式,用vb可以嗎,不用太複雜,能用就行了

15樓:匿名使用者

t1 參考

t2dim i, a, b as integera = cint(text1.text)

for i = 0 to a

b = b + 2 * i + 1

next i

msgbox "總和=" & b, , "結果"

t3dim i, j, k as integerdim p as boolean

dim a, b as integer

k = 1

b = 1

a = 200 '設定上限

for i = 2 to a

p = false

for j = 2 to a

if j >= i then exit forif i mod j = 0 then p = truenext j

if p = false then

print i;

b = b + i

if k mod 5 = 0 then printk = k + 1

end if

next i

print

print "sum = " & b

這句vb**什麼意思(if 242 and (not 22) then),為什麼這結果也是真啊???!!!

16樓:網海1書生

not和and是邏輯運算子,同時也是位運算子,not是按位取反,and是按位與運算。

not 22的結果是-23,而242 and -23的結果是224,這是個非零值,等價於true,所以最終結果就是真了。

17樓:1號阿江

解:在vb中,非0表示true,而0表示false。

因為表示式242 and (not 22)的運算結果為224 '先按位取反,在進行按位與運算

所以結果為真

18樓:匿名使用者

沒有任何比較結果自然為真。

編寫java小程式,要交作業求大佬幫忙

package test public class person public void eat public static void main string args package test public class teacher extends person override public ...

怎樣編寫c程式求1

怎樣編來寫一自 個c程式求1 bai 2 3 4 20 du乙個很簡zhi單的dao寫法 main printf ld s 20 位數比較 來大,用 源int不能滿足,使用long long可以。下面是 include using namespace std void main cout resul...

急求高手幫忙解決問題c語言編寫程式題急

include 函式作用 將陣列 s 的位置在 n1 至 n2 之間的元素,首尾依次交換。也就是第 n1 個元素和第 n2 個元素交換,也就是第 n1 1 個元素和第 n2 1 個元素交換,也就是第 n1 2 個元素和第 n2 2 個元素交換,void fun int s,int n1,int n2...