Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

# Small Basic - Rather Basic question :)

3 replies to this topic

### #1 teatrap

teatrap

• Members
• 121 posts
• OFFLINE
•
• Gender:Male
• Local time:02:37 PM

Posted 18 November 2013 - 09:32 PM

Hey, I've recently found a nice tutorial on small basic (This is lesson 1.5 - here's the online link)so I'm following through it, however  I can't quite get my head around it.

For some reason after 10 entries into the window using this code it doesn't actually return the amount of rainy cities etc, which I'm thinking that it should?

Here's my code :

```
uptop:
If i < 10 Then
TextWindow.WriteLine("")
TextWindow.Write("WHat is the name of a city?" )
TextWindow.Write("How warm is that (in degrees Celsius)? ")
TextWindow.Write("Is it rainy (Y/N)? ")
TextWindow.Write("Is it windy? ")

subtempCount()
subrainycount()
subwindycount()

i = i + 1

If i = 10 Then
suboutput()
EndIf
EndIf

Goto uptop

Sub subtempcount
If temp <= 5 Then
ColdCount = ColdCount + 1
ElseIf temp <= 15 then
CoolCount = CoolCount + 1
elseif temp <= 25 then
WarmCount = WarmCount + 1
EndIf
EndSub

Sub subrainycount
If rainy = "y" Or rainy = "Y" Then
rainycount = rainycount + 1
EndIf
EndSub

Sub subwindycount
If windy = "y" Or "Y" Then
windycount = windycount + 1
EndIf
EndSub

Sub suboutput
suboutput = rainycount + windycount + temp
EndSub

```

I feel that after 10 entries it should return the total amount of rainy / windy cities? Instead it just stops prompting for questions...

Not sure If I've missed a beat or a whole load, I referenced the solution for this (although there were some parts of it missing)

here's a shot of the question at the end of the section :

Any help appreciated

Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
RAM_12063mb
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC

### #2 Sirawit

Sirawit

Bleepin' Brony

• Malware Response Team
• 4,163 posts
• ONLINE
•
• Gender:Male
• Location:Thailand
• Local time:08:37 PM

Posted 19 November 2013 - 11:54 AM

OK. I'm quite not understand much of small basic but I use lot of visual basic so I think it is acceptable.

There are some bugs in your code.

```Sub suboutput
suboutput = rainycount + windycount + temp
EndSub
```

This won't output anything, what you're doing is add rainy/windy city count and temp together. What you need to do maybe something like this:

```Sub suboutput
TextWindow.Write("Cold City Count:"+ ColdCount)
TextWindow.Write("Cool City Count:"+ CoolCount)
TextWindow.Write("Warm City Count:"+ WarmCount)
TextWindow.Write("Hot City Count:"+ HotCount)
TextWindow.Write("Rainy City Count:"+ RainyCount)
TextWindow.Write("Windy City Count:"+ WindyCount)
EndSub
```

Also you forget about Hot City Count. I think Small Basic is case-insensitive so I think other things are ok.

Thank you.

Edited by Sirawit, 19 November 2013 - 11:54 AM.

If I don't reply back to you in 2 days, feel free to send me a PM.

“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.

### #3 teatrap

teatrap
• Topic Starter

• Members
• 121 posts
• OFFLINE
•
• Gender:Male
• Local time:02:37 PM

Posted 20 November 2013 - 07:41 PM

Hey Sirawit - thanks for your response, it works now

One thing though - the 'ColdCount', RainyCount etc, those variables are only created within the actual Subs, that's right isn't it? Thats the only place that I can see them at least...

I'm hoping to move onto Visual Basic after Small Basic, so hopefully I'm not developing any bad habits.

cheers

Operating system_Windows 8.1 Pro with Media Center (9600)
CPU_Intel® Core™ i7-4700MQ CPU @ 2.40GHz
Motherboard_Hewlett-Packard (1966)
RAM_12063mb
Hard Drive_931gb (HGST HTS541010A9E680)
Graphics card_Intel® HD Graphics 4600
Sound card_IDT High Definition Audio CODEC

### #4 Sirawit

Sirawit

Bleepin' Brony

• Malware Response Team
• 4,163 posts
• ONLINE
•
• Gender:Male
• Location:Thailand
• Local time:08:37 PM

Posted 21 November 2013 - 09:36 AM

For your question, those 'ColdCount', etc. had been declared in Public Sub, which means every variable declared in this place can be use by and private sub.

Visual Basic editor will be much much more better than Small basic one, even give you real-time errors before you run the program.

And its still free.(Needed a bit of serial number creation from windows live, but it just 5 mins.)

The thing you must be caution with Visual basic is Variable declaration, you need to do it seperately, not like Small Basic. Like these:

```Public LevelIdent As Integer 'Public Declaration
Public Level As Integer
Private Complete As String 'Private Sub Declaration
Private Settings1 As Boolean

```

You're good to go. Good luck!

If I don't reply back to you in 2 days, feel free to send me a PM.

“You’re lying… just like you were lying to me before. You have to hate me. I’ve been the worst daughter in the world… you should hate me.”

“But I don’t, Nyx. Because, Nyx, I’m your mother, and a mother will always love her daughter, no matter what.” -Past sins by Pen stroke.

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users