Anyone know basic VisualBasic?

it might be that you have case else's in but dont give it an else output, so if one of the values are outside your case points it will fail?

also your dims are within a private sub so from memory they cant be seen outside of that sub

try Private Sub clocksub(ByRef clock As Integer) as As Integer

and

Case 0 To 2
clocksub = 10

instead of cpoints = 10
 
Last edited:
Its been a looooooong while since I used visual basic but it looks like the capoints, dpoints and cpoints variables are declared locally to their own subs, and therefore are not availble to the totals subroutine. Declare them as global variables.
 
I've never tried programming on a PC although I did loads using BBC Basic, how hard is it to program in Visual Basic or is there anything close to BBC Basic.
 
I've converted the subs to functions to return a value to the calling procedure. The call to the total routine then references the totals. That way you avoid global variables. If this is going to be all there is, then globals wouldn't really cause an issue, but if your project gets big and complicated then global variables should be avoided if possible.

In the first function I've changed "Case 2.1 To 3" to "Case 3" as you can't have 2.1 since you're working with integers, and 2 is covered by the previous "Case" statement.

I've also added "Case Else" returning zeros purely for testing.

I've added the three letter variable types to the variable names (for most of them anyway) just because it's then easier to see the variable type you're working with.

I'm guessing it's only you using it so you'll know the options to enter at each point, but might be worth adding input validation to ensure only integers are entered, or maybe display the three input items as part of the final output as a double-check?

Anyway, hope that helps!
 
Last edited:
TBH I don't understand why you need separate subroutines, can't it all be done in one? Presumably execution halts and waits for input at each inputbox statement?
 
I've never tried programming on a PC although I did loads using BBC Basic, how hard is it to program in Visual Basic

VB is a high level language and is a lot different to a language like BASIC. This is especially true if you use VB.Net rather than VB6, although once you can do VB.Net it's not a great jump to C# or any other .Net language.

If you're going to learn a language, either start with Java or C#. Java would be my first choice as it teaches strict OO principals.

Don't think your BASIC knowledge will carry you very far though ;)
 
VB is a high level language and is a lot different to a language like BASIC. This is especially true if you use VB.Net rather than VB6, although once you can do VB.Net it's not a great jump to C# or any other .Net language.

If you're going to learn a language, either start with Java or C#. Java would be my first choice as it teaches strict OO principals.

Don't think your BASIC knowledge will carry you very far though ;)

Thanks I don't think I'll be getting back into it then, at least it's saved me time end effort.
 
TBH I don't understand why you need separate subroutines, can't it all be done in one? Presumably execution halts and waits for input at each inputbox statement?

True, it could. Depends on how complex the project is I guess. If this is all there is, then personally I would've done it as one routine. If it's a bigger project and the sub routines are ever likely to be reused, I'd go the separate routines method. I'm guessing this is all there is for this project though, so one routine would actually better (imho.)
 
Back
Top Bottom