473,411 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Take Pity on a procedural programmer Please

frmMIS.UserName.Text is defaulted to 'sa'
I change it to 'sa1' when logged in as admin.
I hit btnApply.
I want frmMISRoutine.UserName.Text to become 'sa1' immediatly.
I do not want to show the form immediately.
I hit btnRoutines and load frmMISRoutine screen.
I want to see frmMISRoutine.UserName.Text as 'sa1'
How the hell can I do it...my code is below:
I don't mind learning how to write classes/modules but shouldn't this be a
simple enough thing to do. I still think that it is not much use beeing able
to share objects between screens if you have to load that screen straight
away. It doesn't seem very dynamis, what if you wanted to update the value on
4 screens, would you have to show them all?

UserName.Text on both forms is defaulted to 'sa'

' Apply button to set Routines.UserName.Text from 'sa' to 'sa1'
Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnApply.Click
Dim frmMISRoutine As New Routines
frmMISRoutine.UserName.Text = Me.UserName.Text

Me.ClientSize = New System.Drawing.Size(584, 435)
pnlProperties.Visible = False
btnProperties.Enabled = True
btnApply.Visible = False
btnCancel.Visible = False
sbMIS.Text = "Use buttons to navigate the application (e.g.) [Properties
sets the database and log parameters]."
PollDirectory = txtPollDirectory.Text
End Sub

' Open Routines Form. the UserName.Text should be 'sa1'.
Private Sub btnRoutines_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRoutines.Click
Dim frmMISRoutine As New Routines
frmMISRoutine.Show()
Me.Close()
' When this loads Routines UserName is still sa aaarrrrgggghhhhhh!!!
End Sub

Nov 21 '05 #1
4 1018
marcmc wrote:
frmMIS.UserName.Text is defaulted to 'sa'
I change it to 'sa1' when logged in as admin.
I hit btnApply.
I want frmMISRoutine.UserName.Text to become 'sa1' immediatly.
I do not want to show the form immediately.
I hit btnRoutines and load frmMISRoutine screen.
I want to see frmMISRoutine.UserName.Text as 'sa1'
How the hell can I do it...my code is below:
I don't mind learning how to write classes/modules but shouldn't this be a
simple enough thing to do. I still think that it is not much use beeing able
to share objects between screens if you have to load that screen straight
away. It doesn't seem very dynamis, what if you wanted to update the value on
4 screens, would you have to show them all?

UserName.Text on both forms is defaulted to 'sa'

' Apply button to set Routines.UserName.Text from 'sa' to 'sa1'
Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnApply.Click
Dim frmMISRoutine As New Routines
frmMISRoutine.UserName.Text = Me.UserName.Text

Me.ClientSize = New System.Drawing.Size(584, 435)
pnlProperties.Visible = False
btnProperties.Enabled = True
btnApply.Visible = False
btnCancel.Visible = False
sbMIS.Text = "Use buttons to navigate the application (e.g.) [Properties
sets the database and log parameters]."
PollDirectory = txtPollDirectory.Text
End Sub

' Open Routines Form. the UserName.Text should be 'sa1'.
Private Sub btnRoutines_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRoutines.Click
Dim frmMISRoutine As New Routines
frmMISRoutine.Show()
Me.Close()
' When this loads Routines UserName is still sa aaarrrrgggghhhhhh!!!
End Sub


Well your problem seem to be you are dealing with two different Routines
objects. Everytime you do Dim frmMISRoutine As New Routines it makes a
new Routines object and set everything to the default. If you only want
to deal with one object, make a class level variable called
frmMISRoutine and then only use the "new" keyword once.

Public Class XYZ
dim frmMISRoutine as Routines

Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnApply.Click
frmMISRoutine = New Routines
frmMISRoutine.UserName.Text = Me.UserName.Text

Me.ClientSize = New System.Drawing.Size(584, 435)
pnlProperties.Visible = False
btnProperties.Enabled = True
btnApply.Visible = False
btnCancel.Visible = False
sbMIS.Text = "Use buttons to navigate the application (e.g.)
[Properties sets the database and log parameters]."
PollDirectory = txtPollDirectory.Text
End Sub

' Open Routines Form. the UserName.Text should be 'sa1'.
Private Sub btnRoutines_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRoutines.Click
'Dim frmMISRoutine As New Routines
'Now the frmMISRoutine already exists, don't make a new one
frmMISRoutine.Show()
Me.Close()
' When this loads Routines UserName is still sa aarrrrgggghhhhhh!!!
End Sub
Nov 21 '05 #2
I presume that btnApply and btnRoutines are both buttons on the main
form? In that case replace these lines:

Dim frmMISRoutin As New Routines
frmMISRoutine.UserName.Text = Me.UserName.Text

with:

Me.UserName.Text = "sa1"

Nov 21 '05 #3
yes Chris they are on the main form, thankyou and more aaaarrrrggghhhh...

First example says that frmMISRoutine is not declared even though I declare
it within a class called dbProps
The second example does not even come close to ythe requirement i need. I
need to set the textBox on form2 when i hit the apply button on Form1, not
show form3 until button1 is pressed. That is all.

I have programmed in many languages and have never seen a rediculous means
of sharing global variables like this. Insane and Why?
"Chris" wrote:
marcmc wrote:
frmMIS.UserName.Text is defaulted to 'sa'
I change it to 'sa1' when logged in as admin.
I hit btnApply.
I want frmMISRoutine.UserName.Text to become 'sa1' immediatly.
I do not want to show the form immediately.
I hit btnRoutines and load frmMISRoutine screen.
I want to see frmMISRoutine.UserName.Text as 'sa1'
How the hell can I do it...my code is below:
I don't mind learning how to write classes/modules but shouldn't this be a
simple enough thing to do. I still think that it is not much use beeing able
to share objects between screens if you have to load that screen straight
away. It doesn't seem very dynamis, what if you wanted to update the value on
4 screens, would you have to show them all?

UserName.Text on both forms is defaulted to 'sa'

' Apply button to set Routines.UserName.Text from 'sa' to 'sa1'
Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnApply.Click
Dim frmMISRoutine As New Routines
frmMISRoutine.UserName.Text = Me.UserName.Text

Me.ClientSize = New System.Drawing.Size(584, 435)
pnlProperties.Visible = False
btnProperties.Enabled = True
btnApply.Visible = False
btnCancel.Visible = False
sbMIS.Text = "Use buttons to navigate the application (e.g.) [Properties
sets the database and log parameters]."
PollDirectory = txtPollDirectory.Text
End Sub

' Open Routines Form. the UserName.Text should be 'sa1'.
Private Sub btnRoutines_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRoutines.Click
Dim frmMISRoutine As New Routines
frmMISRoutine.Show()
Me.Close()
' When this loads Routines UserName is still sa aaarrrrgggghhhhhh!!!
End Sub


Well your problem seem to be you are dealing with two different Routines
objects. Everytime you do Dim frmMISRoutine As New Routines it makes a
new Routines object and set everything to the default. If you only want
to deal with one object, make a class level variable called
frmMISRoutine and then only use the "new" keyword once.

Public Class XYZ
dim frmMISRoutine as Routines

Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnApply.Click
frmMISRoutine = New Routines
frmMISRoutine.UserName.Text = Me.UserName.Text

Me.ClientSize = New System.Drawing.Size(584, 435)
pnlProperties.Visible = False
btnProperties.Enabled = True
btnApply.Visible = False
btnCancel.Visible = False
sbMIS.Text = "Use buttons to navigate the application (e.g.)
[Properties sets the database and log parameters]."
PollDirectory = txtPollDirectory.Text
End Sub

' Open Routines Form. the UserName.Text should be 'sa1'.
Private Sub btnRoutines_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRoutines.Click
'Dim frmMISRoutine As New Routines
'Now the frmMISRoutine already exists, don't make a new one
frmMISRoutine.Show()
Me.Close()
' When this loads Routines UserName is still sa aarrrrgggghhhhhh!!!
End Sub

Nov 21 '05 #4
Marc,

Place in the load event of your mainform this

dim frm as new frmMisRoutine
frm.mypassword = "whatever"
frm.showdialog
dim myresult as string = frm.mypassword
frm.dispose

In your frmMisRoutine you create

Friend mypassword as string

In the load event of that form you set
TheTextBoxYouWant.Text = mypassword

And before you close you do
mypassword = TheTextBooxYouWant

There are easier methods however this is in my opinion well to understand
the behaviour.

You have to know that VBNet controls have no child controls direct however
VBNet controls (Form is one of those) have only control arrays. It is a
little bit confusing that so many VB6 people have written that the
controlarrays don't exist anymore in VBNet. The way the controlarray as it
was in VB6 does not exist anymore.

I hope that this gives some ideas

Cor
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: pdcjlw1 | last post by:
I am attempting to learn how to program in VisualBasic.Net after many years as a Cobol programmer. I've done some simple things in VisualBasic.net and have a good understainding of SQL, but I still...
3
by: Christian McArdle | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.os.ms-windows.programmer.64bit This is a formal Request For Discussion (RFD) to create comp.os.ms-windows.programmer.64bit as an unmoderated...
4
by: Mark Mikulec | last post by:
Hi there, I wonder if anyone can shed some light on a very frustrating problem. I'm running a debian linux 3.0 "woody" server, nothing special, with the latest version of postres that apt-get...
2
by: John Gabriele | last post by:
The way I've always "designed" procedural C programs has just been to: A. Think about what I need to do B. Draw a flowchart with pencil and paper C. Implement the flowchart in C from the top...
13
by: parley | last post by:
After several years of programming WWW applications in ASP.NET (and several other frameworks) our division has come to what might seem a counterintiutive conclusion: Writing ASP.NET code in a...
16
by: Manuel | last post by:
Please, excuse me for starting this discussion. I'm not a troll, and I love the OOP architecture. However I'm a C++ newbie, and sometimes it's hard for me to fully understand the improvement of...
4
by: Mohitz | last post by:
Any pointers as to how one should go about porting procedural type code into object oriented code?? --- Mohit
3
by: KiranJyothi | last post by:
Hi All, I am new to the software languages and wanted to learn C++. It seems that C++ is neither(completely) an object oriented programming nor(completely) a proceduarl programming. So, I...
2
by: san1014 | last post by:
Hi I have few questions. Pleae give me the answers. 1) In postgreSQL, how to declare and call the cursors in a stored procedural function? Ex: I want to display all the columns in a table in one...
0
by: FLANDERS | last post by:
Hi all, Is it possible to declare a SQL type of result set or similar? I want to do use the IN predicate like you can in a non-procedural SQL like this: UPDATE TABLE1 SET COL1 = 123 WHERE COL2 IN...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.