LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Rob
 
Posts: n/a
Default UserForm TextBoxes

I have created a few UserForms and one of them is for the User to input
various amounts as required.
I'm having some difficulty in understanding how the dim statement works in
determining what the input type that can be entered, etc.

Some things I can't get right a
I want to restrict the input to numbers only.
I want the TextBoxes to be blank and not show a "0" OR have it so that the 0
amount is highlighted so that when the user clicks in the box it overwrites
the 0. (When I use "" instead of 0 when resetting the Textboxes to blank I
get a type missmatch alert.)

Below is my "creation" which may be a bit rough but it works other than the
problems above.

Thanks for azny help!
Rob

Private Sub OK_Click()
Dim L As Integer
Dim G As Integer
Dim C As Integer

L = LoanTextBox.Value 'Loan amount
G = GiftTextBox.Value 'Gift amount
C = LoanGiftTextBox.Value 'Converted (Loan to a Gift) amount

If L = 0 And G = 0 And C = 0 Then
MsgBox "You must enter an amount!"
Exit Sub
End If
If C < 0 And L < 0 Then GoTo Message1
If C < 0 And G < 0 Then
Message1:
MsgBox "You cannot convert a loan and also enter any amounts for Loan or
Gift at the same time!"
LoanTextBox.Value = 0
GiftTextBox.Value = 0
LoanGiftTextBox.Value = 0
Exit Sub
End If
If L < 0 Then
ActiveCell.Offset(0, 1).Value = L
End If
If G < 0 Then
ActiveCell.Offset(0, 2).Value = G
End If
If C ufLoanGift.TextBox1.Text Then
Unload Me
MsgBox "The amount you have entered for convertion to Gift is more than the
total of the Loans for this person."
ufLoanGift.TextBox1.Text = ActiveCell.Offset(0, 6).Value
ufLoanGift.Show
Else
If C < 0 Then
ActiveCell.Offset(0, 1).Value = -C
ActiveCell.Offset(0, 2).Value = C
ActiveCell.Offset(0, 4).Value = Comment
End If
Range("C221").End(xlUp)(1, 3).Select
ActiveCell.Offset(0, 4).ClearContents
ActiveCell.Offset(0, 1).Select
With Sheet1
.PivotTables("PivotTable1").RefreshTable
End With
Unload Me
ufDate.Show
End If
End Sub

Private Sub LoanTextBox_Change()
If C < 0 Then
MsgBox "You cannot enter an amount in this box if there is an amounts in the
Convert Loan to Gift box!"
C = 0
End If
End Sub
Private Sub GiftTextBox_Change()
If C < 0 Then
MsgBox "You cannot enter an amount in this box if there is an amounts in the
Convert Loan to Gift box!"
C = 0
End If
End Sub
Private Sub LoanGiftTextBox_Change()
If L < 0 Then GoTo Message
If G < 0 Then
Message:
MsgBox "You cannot enter an amount in this box if there are amounts in the
Loan or Gift boxes!"
L = 0
G = 0
End If
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm Data to Spreadsheet Andy Tallent Excel Discussion (Misc queries) 2 June 22nd 05 04:51 PM
Auto calculation on a userform Greg B Excel Discussion (Misc queries) 0 June 13th 05 01:51 AM
Data Validation Cell - Move to UserForm thom hoyle Excel Worksheet Functions 0 April 28th 05 12:23 AM
Cell Content from UserForm Not Retained D.Parker Excel Discussion (Misc queries) 3 April 27th 05 04:56 PM
How can I run a macro in the background whilst a UserForm is visib cdb Excel Discussion (Misc queries) 3 February 10th 05 06:58 PM


All times are GMT +1. The time now is 02:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"