Learning VB

05/04/2007 14:47 ganoderma#1
I am currently learning Visual Basic programming.

to learn, a friend taught me some things:
agreement window
Buttons to open other forms
and a simle 'dice' game.

though i wanted an highscore on the dice game and did this:

if form3.highscore.caption < form3.score.caption then
form3.highscore.caption = form3.score.caption
msgbox "new highscore!"
end if

however, this will result in 9 as the perfect score.
10, 11 and 12 are not higher according to the program (if you get it, it wont see that as highscore)

can anybody help me with this?
i can send the program itself or the source code if you need it.
05/04/2007 15:00 newn01#2
i think this tread is off topic here ehh? its not about conquer online.
05/04/2007 15:02 ganoderma#3
well,
you might be right about that but there isnt any section for programming in general and i probably forget that i posted it anywhere else if i do.

EDIT//
here is a zip file of the dource and the program itself.
[Only registered and activated users can see links. Click Here To Register...]

(dice game.exe is the program, the rest is the source for visual basic)
05/04/2007 15:31 bone-you#4
What are you learning it for? Anything in particular or just to learn it? If you're just looking for a language to learn might I recommend c++? :) I never liked VB back when I took it in school. I'll take a look though. Basic syntaxes are the same and it's still just logic.

edit:
well I looked at it. It appears you're comparing strings and not numbers. You're also using a string class to work them. Try turning them into integers or something.. I forget what it is in vb. dim as int? or whatever it is :P It should work then.

edit2:
fixed it.

Form2:
add to function start_Click
Code:
    If &#40;Me.Highscore.Text = &#34;&#34;&#41; Then
      Me.Highscore.Text = &#34;0&#34;
    End If
to stopknop_Click - replace
Code:
    If &#40;CDbl&#40;Me.Highscore.Text&#41; &#60; CDbl&#40;Me.Score.Text&#41;&#41; Then
:) works fine.
05/04/2007 15:57 ganoderma#5
thanks :)
needed a little editing to VB language and my names but it works :)
05/04/2007 19:20 booboohead#6
Quote:
Originally posted by ganoderma@May 4 2007, 14:47
I am currently learning Visual Basic programming.

to learn, a friend taught me some things:
agreement window
Buttons to open other forms
and a simle 'dice' game.

though i wanted an highscore on the dice game and did this:

if form3.highscore.caption < form3.score.caption then
form3.highscore.caption = form3.score.caption
msgbox "new highscore!"
end if

however, this will result in 9 as the perfect score.
10, 11 and 12 are not higher according to the program (if you get it, it wont see that as highscore)

can anybody help me with this?
i can send the program itself or the source code if you need it.
The problem is that it's a string compare. It's like a dictionary...

The data type for the caption is a string, in a dictionary, you sort strings as such.


Ed
Edward
Edwardo <== misspelled, I know.

Anyhow, you would see that with this logic the sorting for numbers would be like:
1
11
15
19
2
21
25
3
35
etc...

So, you need to convert that string to a number and do a NUMERIC comparison, not a string comparison.
Convert a string to an integer with the Val() function.

if Val(form3.highscore.caption) < Val(form3.score.caption) then
form3.highscore.caption = form3.score.caption
msgbox "new highscore!"
end if

Good day.