What does Loop without Do mean in this context??
Loop While FTemp <> ""
Printable View
What does Loop without Do mean in this context??
Loop While FTemp <> ""
You have to have a do statement at the beginning of your loop and the Loop While statement at the end.
Looks like a neverending loop to me though, be careful!Code:Do
' your code here
Loop While ftemp <> ""
:eek:
Prompt = "Enter a Farenheit temperature."
If FTemp <> "" Then
Celcius = Int((FTemp + 40) * 5 / 9 + 40)
MsgBox (Celsius), , "Temperature in Celcius"
End If
Loop While FTemp <> ""
This is the code I have, the book has the code that way, aaarrrggghhh!
What book is that!???
is there more to that code? that wont work at all!
Code:'there is no use for prompt...like an InputBox
'there is no DO for this loop!
Prompt = "Enter a Farenheit temperature." 'Ok...but where do I enter it!!! :)
If FTemp <> "" Then
Celcius = Int((FTemp + 40) * 5 / 9 + 40)
MsgBox (Celsius), , "Temperature in Celcius"
End If
Loop While FTemp <> ""
Try This instead..
If that is how the code is in the book, find the closest source of fire and burn it! ;)Code:Do
Prompt = "Enter a Farenheit temperature."
FTemp = InputBox(Prompt)
If FTemp <> "" Then
Celcius = (Int(FTemp) + 40) * 5 / 9 + 40
MsgBox Str(Celcius), , "Temperature in Celcius"
End If
Loop While FTemp <> ""
I'm sure you're lost the Do in somewhere else. 'coz loop will not be able to work if Do syntax is not there.
Chris
Geoff,
This is the VB 6 book by Microsoft... Michael Halvorson
Talk about annoying the amount of errors and here I am, sorta getting the hang of it and then I get totally floored by something that makes no sense at all!
I'll try your suggestion and thanks!
Code:
Private Sub Command1_Click()
Dim prompt As String
prompt = "Enter a Farenheit temperature."
FTemp = InputBox(prompt, "Temp")
If FTemp = "" Then
Exit Sub
Else
'where this came from who could guess
'this gives 32 R as 80 c when in fact it is 0
Celcius = Int((FTemp + 40) * 5 / 9 + 40)
'I don't know the exact formula its -32/.something
MsgBox FTemp & " Farenheit = " & Celcius & " Temperature in Celcius"
End If
End Sub
I hadn't noticed the formula is wrong! Excelent work Microsoft!
should beCode:Celcius = Int((FTemp + 40) * 5 / 9 + 40)
:)Code:Celcius = Int((FTemp -32) * 5 /9)
Code:
Fahrenheit = Int((FTemp *9 /5)+32)