| View previous topic :: View next topic |
| Author |
Message |
Wiw3K Grandmaster Cheater
Reputation: 0
Joined: 09 Jul 2006 Posts: 762 Location: Poland.
|
Posted: Mon Dec 15, 2008 3:48 pm Post subject: [VB 6]Little help needed :P (Answered) |
|
|
ok so i made thread about the same but in VC++, i also know more VB so better when i go on with VB instead VC.
1.I Have Text1 where i need to put number.
2.Click a Button then it will be divided by 3 then multiplicated by 2.
3.Result have to appear in Text2.
umm i did this:
| Code: | Private Sub Command1_Click()
Text2 = Val(Tekxt1.Text) / 3 * 2
End Sub |
but does not work xD idk why if someone can explain me how to fix it?
Last edited by Wiw3K on Mon Dec 15, 2008 4:27 pm; edited 1 time in total |
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Mon Dec 15, 2008 4:01 pm Post subject: |
|
|
Private Sub Command1_Click()
Text2.Text = Val(Tekxt1.Text) / 3 * 2
End Sub
done
but I recommend you to use labels to show values
Last edited by gogodr on Mon Dec 15, 2008 4:01 pm; edited 1 time in total |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Dec 15, 2008 4:01 pm Post subject: |
|
|
I've never used VB6, but this seems right enough
TextBox2.Text = CStr(CInt(TextBox1.Text) / 3 * 2)
|
|
| Back to top |
|
 |
Wiw3K Grandmaster Cheater
Reputation: 0
Joined: 09 Jul 2006 Posts: 762 Location: Poland.
|
Posted: Mon Dec 15, 2008 4:15 pm Post subject: |
|
|
| slovach wrote: | I've never used VB6, but this seems right enough
TextBox2.Text = CStr(CInt(TextBox1.Text) / 3 * 2) |
ty for help alot but gogodr answer works
| gogodr wrote: | Private Sub Command1_Click()
Text2.Text = Val(Tekxt1.Text) / 3 * 2
End Sub
done
but I recommend you to use labels to show values |
ok everything ok i want now make not show like 23.233333
eg.
23
press button
15,333333 appear , i want to show 15 only , not 15,333333
how i can do that?
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Mon Dec 15, 2008 4:23 pm Post subject: |
|
|
| Wiw3K wrote: | | slovach wrote: | I've never used VB6, but this seems right enough
TextBox2.Text = CStr(CInt(TextBox1.Text) / 3 * 2) |
ty for help alot but gogodr answer works
| gogodr wrote: | Private Sub Command1_Click()
Text2.Text = Val(Tekxt1.Text) / 3 * 2
End Sub
done
but I recommend you to use labels to show values |
ok everything ok i want now make not show like 23.233333
eg.
23
press button
15,333333 appear , i want to show 15 only , not 15,333333
how i can do that? |
you can use
Round()
or
Trunk()
Private Sub Command1_Click()
Text2.Text = Round(Val(Tekxt1.Text) / 3 * 2,0 )
End Sub
or
Private Sub Command1_Click()
Text2.Text = Trunk(Val(Tekxt1.Text) / 3 * 2,0 )
End Sub
--------------
round , rounds the number
and Trunk just deletes the decimals
|
|
| Back to top |
|
 |
Wiw3K Grandmaster Cheater
Reputation: 0
Joined: 09 Jul 2006 Posts: 762 Location: Poland.
|
Posted: Mon Dec 15, 2008 4:26 pm Post subject: |
|
|
| gogodr wrote: |
you can use
Round()
or
Trunk()
Private Sub Command1_Click()
Text2.Text = Round(Val(Tekxt1.Text) / 3 * 2,0 )
End Sub
or
Private Sub Command1_Click()
Text2.Text = Trunk(Val(Tekxt1.Text) / 3 * 2,0 )
End Sub
--------------
round , rounds the number
and Trunk just deletes the decimals |
Round method works wery vell Thank you again.
Trunk ~ Gives error something not defined.
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Dec 15, 2008 6:02 pm Post subject: |
|
|
| Don't use a floating point value
|
|
| Back to top |
|
 |
|