|
-
Aug 26th, 2007, 01:39 PM
#1
Thread Starter
Member
-
Aug 26th, 2007, 02:09 PM
#2
Re: Division with remainders
 Originally Posted by Snowfox
Also: i would like someone to tell me how to use the enter key with text1.text = "Enter"?
Use the Textbox's KeyUp Event:
vb Code:
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then 'Check if return Key was pressed
Call Command1_Click
End If
End Sub
But you will have to build in some sort of error tapping just in case the user does enter a value in either of the Textboxes. Otherwise a nice piece of code.
Last edited by Mark Gambo; Aug 26th, 2007 at 02:13 PM.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Aug 26th, 2007, 02:20 PM
#3
Thread Starter
Member
Re: Division with remainders
Thats not what i meant, i mean like in a multi line enabled textbox how do i use Text1.text = "{enter}" Which would skip a line.
-
Aug 26th, 2007, 02:34 PM
#4
Re: Division with remainders
 Originally Posted by Snowfox
Thats not what i meant, i mean like in a multi line enabled textbox how do i use Text1.text = "{enter}" Which would skip a line.
I don't understand? If you hold down the Control Key and Press the Return key the cursor will then go to the next line in the textbox provided that the Multiline property is set to True.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Aug 26th, 2007, 02:40 PM
#5
-
Aug 26th, 2007, 03:57 PM
#6
Re: Division with remainders
This seems overcoded to me. Much simpler would be:
Code:
Private Sub Command1_Click()
Dim lngDividend As Long
Dim lngDivisor As Long
Dim lngQuotient As Long
Dim lngRemainder As Long
lngDividend = Val(Text1.Text)
lngDivisor = Val(Text2.Text)
lngQuotient = lngDividend \ lngDivisor
lngRemainder = lngDividend Mod lngDivisor
Label1.Caption = lngQuotient & " r " & lngRemainder
Text3.Text = lngQuotient & " * " & lngDivisor & " = " & lngQuotient * lngDivisor & vbNewLine & _
lngQuotient * lngDivisor & " + " & lngRemainder & " = " & lngQuotient * lngDivisor + lngRemainder
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|