vb為什麼else沒有if,vb6 0 else沒有if 問題

時間 2022-03-05 20:35:07

1樓:風箏的天空藍耀

private sub command1_click()if b > 100 then

text1.backcolor = vbredelse

text1.backcolor = vbblueend if

end sub

private sub form_load()b = val(text1.text)

end sub

這樣既可,你直接在then後面加語句就不用end if結束了而你有寫了else即表明重新的乙個if語句

2樓:續甫年恨桃

你在elseifb=

"\"then的前面是否有個if......then?

若沒有肯定出錯,就把else去年就可以了

另外,elseif最好寫成

else

if......then

這樣層次會清楚些

3樓:匿名使用者

把這一句:

if b > 100 then text1.backcolor = vbred

改成兩行:

if b > 100 then

text1.backcolor = vbred

vb6.0 else沒有if 問題

4樓:匿名使用者

你要在then後回車,才可以使用else。否則的話它會將if……then……當成一句話,下面的else就沒有匹配的if了。

5樓:匿名使用者

是由於if語法錯誤:

1、檢視最後是否有endif

2、如果不行,仔細核對每乙個if,看看有沒有與其配對的end if

6樓:匿名使用者

改為:private sub command1_click()dim a, b, c as singledim d as string

a = val(text1)

b = val(text2)

d = text3

if text3 = "+" then c = a + belseif text3 = "-" then c = a - belseif text3 = "*" then c = a * belse text3 = "/" then c = a / bend if

text4 = c

end sub

vb為什麼老說else沒有if

7樓:

if index = 0 then

text1.text = ""

'這個要分開兩行寫,要不然就認為是乙個單行if語句。

8樓:匿名使用者

if 條件1 then

語句1elseif 條件2 then

語句2end if

上述是if塊結構得標準寫法。

private sub command2_click(index as integer)

if index = 0 then

text1.text = ""

elseif signfleg = true thenselect case c

case 1

text1.text = a + b

case 2

text1.text = a - b

case 3

text1.text = a * b

case 4

text1.text = a / b

end select

end if

end sub

9樓:匿名使用者

if index = 0 then text1.text = "" --- 這是完整的單行if結構

elseif signfleg = true then --- 此處的elseif當然缺少if了

修改成if index = 0 then

text1.text = ""

elseif signfleg = true then

10樓:肆晚圈

if index = 0 then text1.text = ""

elseif signfleg = true then'錯誤if index = 0 then

text1.text = ""

elseif signfleg = true then'這個要分開兩行寫,要不然就認為是乙個單行if語句。

11樓:

第二句是全整的if句子,

第三句又是另乙個單獨的了,所以是走了if的

12樓:匿名使用者

其實很簡單,只要你在程式最後再加乙個 end if 就行了

13樓:藍色的多瑙河

then後面的語句塊另起一行,不要直接接語句塊。

vb提示else中沒有if

14樓:

你的那個x定義成了整形,而你的賦值語句「x = text1.text」卻把text內的字串給了x,試問這樣的你的for語句,if語句能不錯嗎?

修改一下試試,x=val(text1)

15樓:匿名使用者

private sub command1_click()dim m, n, x as integerx = text1.text

dim a(1 to 100, 1 to 100), b(1 to 100, 1 to 100) as integer

for m = 1 to x

for n = 1 to x

if n < (x - m) then

picture1.print spc(x - m)elseif n = (x - m + 1) thena(m, n) = 1 & a(m - 1, x) = 0picture1.print a(m, n) & " "

else

a(m, n) = a(m - 1, n) + a(m - 1, n + 1)

end if

next n

next m

end sub

大概是因為你把語句直接根在then後面了。

vb編譯錯誤 else 沒有if 但是明明寫了if

16樓:

更改方法一:

private sub command1_click()

if val(text1) < 40 or val(text2) < 40 or val(text3) < 40 then

text4 = "不合格"

elseif val(text1) < 60 or val(text2) < 60 or val(text3) < 60 then text4 = "達標"

else

text4 = "合格"

end if

text5 = format(((val(text6) + val(text7) + val(text8)) / 3), "00.0")

end sub

更改方法二:要是我的話就會是這樣寫的。

private sub command1_click()

if val(text1) < 40 or val(text2) < 40 or val(text3) < 40 then

text4 = "不合格"

elseif val(text1) < 60 or val(text2) < 60 or val(text3) < 60 then

text4 = "達標"

else

text4 = "合格"

end if

text5 = format(((val(text6) + val(text7) + val(text8)) / 3), "00.0")

end sub

17樓:匿名使用者

if 格式不對

if elseif

elseif

end if

看懂了嗎,程式設計不是造句,有些地方要注意

vb中else 沒有if錯誤

18樓:麥兜

在語句羅列不清的時候你應當換一種語法寫而不會造成**編寫過於死板

'這是按照你的寫法

private sub text1_gotfocus()

text1.text = ""

dim i$, num1%, num2%

num1 = 0

num2 = 0

i = text1.text

while i <> vbcrlf

if i = "(" then

num1 = num1 + 1

elseif i = ")" then num2 = num2 + 1

end if

wend

if num1 < num2 then

print "右圓括號多於左圓括號"

elseif num1 > num2 then print "左圓括號多於右圓括號"

else: print "左右圓括號配對"

end if

end sub

'個人建議這樣寫

private sub text1_gotfocus()

text1.text = ""

dim i$, num1%, num2%

num1 = 0

num2 = 0

i = text1.text

while i <> vbcrlf

if i = "(" then num1 = num1 + 1

if i = ")" then num2 = num2 + 1

wend

if num1 < num2 then print "右圓括號多於左圓括號"

if num1 > num2 then print "左圓括號多於右圓括號" else print "左右圓括號配對"

end sub

'如果是這種寫法最好

private sub text1_gotfocus()

text1.text = ""

dim i$, num1%, num2%

num1 = 0

num2 = 0

i = text1.text

while i <> vbcrlf

select case i

case "("

num1 = num1 + 1

case ")"

num2 = num2 + 1

end select

wend

if num1 < num2 then print "右圓括號多於左圓括號"

if num1 > num2 then print "左圓括號多於右圓括號" else print "左右圓括號配對"

end sub

19樓:幹嗎尋找周杰倫

else: print "左右圓括號配對"

是不是這個else後面的冒號的問題

對vb字元處理還真不熟悉

20樓:匿名使用者

需要完整**才能判斷,vb很多時候其他地方出錯怪罪到其他地方的

VB問題 急!為什麼會出現這種情況?

把變數宣告部分放在按鈕事件內部。private sub command1 click dim n as double,k as long,s as double,i as double,j as double end sub 放在所有模組之外的話,會當做公共變數來處理,過程結束後會保留原來的值。將變...

VB為什麼會流行一時,又為什麼會衰敗

呵呵,玩笑麼,vb怎麼可能真的像過家家了,只是說不適合專門學習運用程式設計的人使用罷了。vb像小孩子過家家?不是吧。這話說的太狠了吧。這麼說,學vb的都不如3,4歲小孩了。語法通俗易學!功能有限,微軟有新的發展方向vs vb的基礎是basic語言,你去查查basic這個單詞代表的意義就知道了 因為語...

在vb裡,我呼叫beep函式,為什麼發不出聲音啊,我是希望當文字框的輸出的數值大於某個數時就發出聲音

vb裡,不能寫成call beep 2000,3000 直接寫beep即可。if temptext.text 13 thenbeep end if 如果嫌聲音不好,想改變聲音,就得使用api了。private declare function beep lib kernel32 byval dwfr...