![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2005
Posts: 52
Rep Power: 3
![]() |
stuck....
Hi everyone fairly new to VB .Net so i don't know too much. I'm currently trying to make an event but i'm not sure how to do it. What i have is two text boxes and two buttons. each text box has a value inside (lets just say 3). when one button is enabled the other is disabled and vise versa. if i click the button i want the value of the box on one side to double, but only until the next turn (next time that button becomes enabled), then it should reset back to it's original value. I thought of using a gain focus but then everytime that the button on either side gains focus it divides each value by two (instead of doubling i was trying to divide by two to return the text number back to it's original value). Anyone have any ideas how i can accomplish this?
|
|
|
|
|
|
#2 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
Can you explain explain your problem in pseudo code?
|
|
|
|
|
|
#3 |
|
Programmer
Join Date: Oct 2005
Posts: 52
Rep Power: 3
![]() |
txtbox1 (number 3 inside), btn1 (enabled)
txtbox2 (same number inside), btn2 (disabled) btn1.click double the value of txtbox1 disable btn1 enable btn2 btn2.click disable btn2 enable btn1 check 2 see if txtbox1 is double if so divide by 2 |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
Just Sub Main to it and the code is completed ^_^
Imports System Imports System.Drawing Imports System.Windows.Forms Namespace DefaultNamespace Public Class Form1 Inherits System.Windows.Forms.Form Private oldvalue As Integer Private label2 As System.Windows.Forms.Label Private label1 As System.Windows.Forms.Label Private Text2 As System.Windows.Forms.TextBox Private Bt2 As System.Windows.Forms.Button Private Bt1 As System.Windows.Forms.Button Private Text1 As System.Windows.Forms.TextBox Public Sub New() MyBase.New ' ' The Me.InitializeComponent call is required for Windows Forms designer support. ' Me.InitializeComponent ' ' TODO : Add constructor code after InitializeComponents ' End Sub #Region " Windows Forms Designer generated code " ' This method is required for Windows Forms designer support. ' Do not change the method contents inside the source code editor. The Forms designer might ' not be able to load this method if it was changed manually. Private Sub InitializeComponent() Me.Text1 = New System.Windows.Forms.TextBox Me.Bt1 = New System.Windows.Forms.Button Me.Bt2 = New System.Windows.Forms.Button Me.Text2 = New System.Windows.Forms.TextBox Me.label1 = New System.Windows.Forms.Label Me.label2 = New System.Windows.Forms.Label Me.SuspendLayout ' 'Text1 ' Me.Text1.Location = New System.Drawing.Point(64, 8) Me.Text1.Name = "Text1" Me.Text1.TabIndex = 2 Me.Text1.Text = "3" ' 'Bt1 ' Me.Bt1.Location = New System.Drawing.Point(208, 232) Me.Bt1.Name = "Bt1" Me.Bt1.TabIndex = 0 Me.Bt1.Text = "Bt1" AddHandler Me.Bt1.Click, AddressOf Me.Bt1Click ' 'Bt2 ' Me.Bt2.Enabled = false Me.Bt2.Location = New System.Drawing.Point(320, 232) Me.Bt2.Name = "Bt2" Me.Bt2.TabIndex = 1 Me.Bt2.Text = "Bt2" AddHandler Me.Bt2.Click, AddressOf Me.Bt2Click ' 'Text2 ' Me.Text2.Location = New System.Drawing.Point(240, 8) Me.Text2.Name = "Text2" Me.Text2.TabIndex = 3 Me.Text2.Text = "3" ' 'label1 ' Me.label1.Location = New System.Drawing.Point(8, 8) Me.label1.Name = "label1" Me.label1.Size = New System.Drawing.Size(48, 24) Me.label1.TabIndex = 4 Me.label1.Text = "Text1" ' 'label2 ' Me.label2.Location = New System.Drawing.Point(192, 8) Me.label2.Name = "label2" Me.label2.Size = New System.Drawing.Size(48, 24) Me.label2.TabIndex = 5 Me.label2.Text = "Text2" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(400, 262) Me.Controls.Add(Me.label2) Me.Controls.Add(Me.label1) Me.Controls.Add(Me.Text2) Me.Controls.Add(Me.Text1) Me.Controls.Add(Me.Bt2) Me.Controls.Add(Me.Bt1) Me.Name = "Form1" Me.Text = "Form1" AddHandler Load, AddressOf Me.Form1Load Me.ResumeLayout(false) End Sub #End Region Private Sub Form1Load(sender As System.Object, e As System.EventArgs) oldvalue = 3 End Sub Private Sub Bt1Click(sender As System.Object, e As System.EventArgs) Text1.Text = (Convert.ToInt32(Text1.Text) * 2).ToString() Bt1.Enabled = False Bt2.Enabled = True End Sub Private Sub Bt2Click(sender As System.Object, e As System.EventArgs) Bt1.Enabled = true Bt2.Enabled = False If(Convert.ToInt32(Text1.Text) > oldvalue) Text1.Text = (Convert.ToInt32(Text1.Text) / 2).ToString oldvalue = Convert.ToInt32(Text1.Text) End If End Sub End Class End Namespace |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
dude, with your psudocode you answered your own question, your logic is fine. don't be afraid to try stuff. do you not know what to "click" on or something?
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|