|
-
Jan 13th, 2006, 02:53 PM
#1
Thread Starter
Member
programming question
I am doing a project--trying to make a sales receipt. I am having problems trying to get the ItemPrice to the Receipt after clicking the button.
Can anyone help me?
-
Jan 13th, 2006, 02:58 PM
#2
Re: programming question
I'm sure someone would be willing to help. However, your post is vague and you're not giving any specific code with a specific problem you need help with. I have no idea what's the "ItemPrice" and what's the "button" you're talking about.
-
Jan 13th, 2006, 03:02 PM
#3
Hyperactive Member
Re: programming question
Ehat do you mean Receipt ?? Do you mean Crystal report or something ?
do you want to the item price to be in the report ?? what do you mean ?
My software never has bugs. It just develops random features.
I RATE, YOU RATE!!!
-
Jan 13th, 2006, 03:04 PM
#4
Thread Starter
Member
Re: programming question
When you enter in a Item Price in the first text box, Like say the Item was $10.00.
I need that $10.00 (which that text box is called ItemPriceText) after clicking the button(button1) to go over to the Sales Receipt (SalesReceiptLabel)
-
Jan 13th, 2006, 03:07 PM
#5
Re: programming question
If I understand correctly:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SalesReceiptLabel.Text = ItemPriceText.Text
End Sub
-
Jan 13th, 2006, 03:10 PM
#6
Thread Starter
Member
Re: programming question
I tried doing that but it said that SalesRecieptLabel is not declared
-
Jan 13th, 2006, 03:12 PM
#7
Re: programming question
You said that the label is called "SalesReceiptLabel". Please post your code so far so we can see what the problem is.
-
Jan 13th, 2006, 03:13 PM
#8
Thread Starter
Member
Re: programming question
ublic Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents ItemPrice As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents ReceiptLabel As System.Windows.Forms.Label
Friend WithEvents ItemPriceText As System.Windows.Forms.TextBox
Friend WithEvents SubTotalText As System.Windows.Forms.TextBox
Friend WithEvents SalesTaxText As System.Windows.Forms.TextBox
Friend WithEvents TotalText As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ItemPrice = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Label3 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.ReceiptLabel = New System.Windows.Forms.Label
Me.ItemPriceText = New System.Windows.Forms.TextBox
Me.SubTotalText = New System.Windows.Forms.TextBox
Me.SalesTaxText = New System.Windows.Forms.TextBox
Me.TotalText = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'ItemPrice
'
Me.ItemPrice.Location = New System.Drawing.Point(8, 24)
Me.ItemPrice.Name = "ItemPrice"
Me.ItemPrice.Size = New System.Drawing.Size(72, 16)
Me.ItemPrice.TabIndex = 0
Me.ItemPrice.Text = "Item Price"
Me.ItemPrice.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(8, 72)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(88, 24)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Add to Receipt"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(112, 24)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(96, 16)
Me.Label3.TabIndex = 3
Me.Label3.Text = "Sales Receipt"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(232, 232)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 32)
Me.Button2.TabIndex = 8
Me.Button2.Text = "E&xit"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(184, 176)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(64, 16)
Me.Label1.TabIndex = 9
Me.Label1.Text = "Sub Total"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(184, 208)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(56, 16)
Me.Label2.TabIndex = 10
Me.Label2.Text = "Sales Tax"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(184, 240)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(40, 16)
Me.Label4.TabIndex = 11
Me.Label4.Text = "Total"
'
'ReceiptLabel
'
Me.ReceiptLabel.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.ReceiptLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.ReceiptLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark
Me.ReceiptLabel.Location = New System.Drawing.Point(104, 40)
Me.ReceiptLabel.Name = "ReceiptLabel"
Me.ReceiptLabel.Size = New System.Drawing.Size(128, 96)
Me.ReceiptLabel.TabIndex = 4
'
'ItemPriceText
'
Me.ItemPriceText.Location = New System.Drawing.Point(8, 40)
Me.ItemPriceText.Name = "ItemPriceText"
Me.ItemPriceText.Size = New System.Drawing.Size(80, 20)
Me.ItemPriceText.TabIndex = 12
Me.ItemPriceText.Text = ""
'
'SubTotalText
'
Me.SubTotalText.BackColor = System.Drawing.SystemColors.InactiveBorder
Me.SubTotalText.Location = New System.Drawing.Point(104, 168)
Me.SubTotalText.Name = "SubTotalText"
Me.SubTotalText.Size = New System.Drawing.Size(80, 20)
Me.SubTotalText.TabIndex = 13
Me.SubTotalText.Text = ""
'
'SalesTaxText
'
Me.SalesTaxText.BackColor = System.Drawing.SystemColors.InactiveBorder
Me.SalesTaxText.Location = New System.Drawing.Point(104, 200)
Me.SalesTaxText.Name = "SalesTaxText"
Me.SalesTaxText.Size = New System.Drawing.Size(80, 20)
Me.SalesTaxText.TabIndex = 14
Me.SalesTaxText.Text = ""
'
'TotalText
'
Me.TotalText.BackColor = System.Drawing.SystemColors.InactiveBorder
Me.TotalText.Location = New System.Drawing.Point(104, 232)
Me.TotalText.Name = "TotalText"
Me.TotalText.Size = New System.Drawing.Size(80, 20)
Me.TotalText.TabIndex = 15
Me.TotalText.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.TotalText)
Me.Controls.Add(Me.SalesTaxText)
Me.Controls.Add(Me.SubTotalText)
Me.Controls.Add(Me.ItemPriceText)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.ReceiptLabel)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ItemPrice)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub ItemPrice_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ItemPrice.Click
End Sub
Private Sub ItmPrLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub ReceiptLabel_ChangeUICues(ByVal sender As Object, ByVal e As System.Windows.Forms.UICuesEventArgs) Handles ReceiptLabel.ChangeUICues
End Sub
Private Sub ReceiptLabel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ReceiptLabel.Click
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
SalesReceiptLabel.Text = ItemPriceText.Text
End Sub
Private Sub ItemPriceText_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ItemPriceText.Click
Dim ItemPriceText As Single
ItemPriceText = FormatCurrency(ItemPriceText)
End Sub
End Class
-
Jan 13th, 2006, 03:15 PM
#9
Thread Starter
Member
Re: programming question
I'm very new to this as you can tell. Would it be easier for me to send it to you, so you can see how it works thus far?
-
Jan 13th, 2006, 03:17 PM
#10
Re: programming question
The label is called ReceiptLabel. Try:
VB Code:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ReceiptLabel.Text = ItemPriceText.Text
End Sub
-
Jan 13th, 2006, 03:17 PM
#11
Thread Starter
Member
Re: programming question
After I get that $10.00 (from the ItemPriceText) to the SalesReceiptLabel, I have to add $9.99 to the ReceiptLabel as well.
-
Jan 13th, 2006, 03:18 PM
#12
Re: programming question
 Originally Posted by Oneworkngrl
I'm very new to this as you can tell.
No problem, that's what the forum is for. If possible, try wrapping code with the VBCode tags (there is a VBCode button on the message window when you create a post).
-
Jan 13th, 2006, 03:20 PM
#13
Thread Starter
Member
Re: programming question
Thank you very much!!! I can't tell how how much this has been bugging me!
-
Jan 13th, 2006, 03:29 PM
#14
Thread Starter
Member
Re: programming question
To add to the Receipt do I use:
ReceiptLabel.Items.Add(ItemPriceText)?
-
Jan 13th, 2006, 03:39 PM
#15
Re: programming question
I'm guessing that you need ReceiptLabel to hold a list of items. You're using a Label control (so .Items.Add is inapplicable - for this you would need something like a ListBox). However, you can get to what you need by using:
VB Code:
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ReceiptLabel.Text += "$" + ItemPriceText.Text + vbCrLf
End Sub
I assume that you'll want to calculate totals also. For this, you should first set the SubTotalText textbox to 0 in your form's load event:
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SubTotalText.Text = "0.00"
End Sub
Then, as items are added you should add code to your button handler (the Button1_Click sub you have in the code) in order to do the addition. You should try to convert the text entered in the ItemPriceText textbox to a double number (use Convert.ToDouble for that) - then do the same to the text in SubTotalText textbox and add them both together. Finally, convert the result to text (use Convert.ToString) and enter the new value in the SubTotalText textbox.
-
Jan 13th, 2006, 03:41 PM
#16
Thread Starter
Member
Re: programming question
Oh my goodness! I am so grateful to you!
-
Jan 13th, 2006, 03:43 PM
#17
Thread Starter
Member
Re: programming question
I have been stuck on this for like days!
-
Jan 13th, 2006, 04:25 PM
#18
Fanatic Member
Re: programming question
Hey oneworkngrl, I can't help you, but it's cool to see a girl programmer. I'm sure yo sexy as hell. good luck!
-
Jan 13th, 2006, 04:56 PM
#19
Thread Starter
Member
-
Jan 13th, 2006, 04:58 PM
#20
Thread Starter
Member
Re: programming question
Ok....Now I got another question--I can't get the Receipt Label to add additional numbers from the ItemPriceText.
Oh, boy! Am I having frustrating day!
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
|