|
Hi
You can do this in many ways. I will suggest 2 ways.
1.
Create property on form2... (Say User) and set that property after initialize form2 class.
Set the property value to label on it in the form_load
Sample code written on VB 2005
Public Class Form2
'Use property for this
Public user As String
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Label1.Text = user
End Sub
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f2 As Form2 = New Form2()
f2.user = Me.txtLogin.Text
f2.ShowDialog()
End Sub
End Class
2.
Create constructor in Form2 in order to pass string (Public sub New (user as string))
And pass textbox value then you initialize Form2.
Set the passed value to label on it in the form_load
No sample code .. (i didnot check this should be work)
Try those. Guaranteed to work well
Regards,
chandana
|
|
|
|
|
On form2 I have set Public username as String.
On frmlogin this is the code for the ok button when you type in the username and passwoed.
If txtpassword.text = frmlogin.tag Then
Dim secondforum As New Form2
secondform.username = txtusername.text
secondform.show
me.hide
Else
msgbox "Try Again"
End If
On form2 under Forum Load I have form2.caption = username
For some reason the username does not go over to form2. I tried to use F8 to see if the username was being seen in Public username as String but for some reason when in F8 mode it won't skip over to the second form code so I can hover over it with mouse and check.
*EDIT*
Ok I got it to work not sure what did it though. But aftering changing secondform.username = txtusername.text to secondform.username = me.txtusername.text it worked.
And on form2 useing me.caption = username.
Thank you for the help!
-- modified at 19:05 Monday 6th March, 2006
|
|
|
|
|
The best way to do this is store the username in a global variable in the login screen. This variable can be accessed throughout the application.
With Best Regards,
Mayur
-- modified at 23:22 Monday 6th March, 2006
|
|
|
|
|
I have two forms
- Form1
- Form2
On Form1 i have textbox and button
On Form2 i have listbox and button
----------------------------------
I need that if u click on form1 on button that the form2 shows up...
Now on form2 u select an one of 100 items...
U click on button "Insert" and the form2 closes.
The textbox gets the selected item text, buth in position where was the (Ibeam - the cursor i dont know how to explain the line "|" when u typeing.)
----------------------------------
I have tried in manny ways buth can't doo it...
For now i did it like this buth not working:
<code>
Dim sX As Integer
Dim lin As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sX = TextBox1.SelectionStart
lin = TextBox1.Lines.GetValue(TextBox1.SelectionStart)
Dim f As New Form2
f.ShowDialog()
TextBox1.Select(sX, 0)
TextBox1.Lines(lin).Insert(sX, f.ListBox1.SelectedItem)
End Sub
</code>
Please help me... Thanks
FeRtoll Software.net
--------------------
I fertoll@net.hr I
--------------------
|
|
|
|
|
Please let me know what is your problem?? And what exactly you want to do
regards,
chandana
|
|
|
|
|
Chandana Subasinghe wrote: Please let me know what is your problem?? And what exactly you want to do
lol...
i did told u up there!!!
------------------------
I need that the selected item in listbox on other form goes to first form in text buth in the place where i was typeing...
thats all...
Need to save focus....
FeRtoll Software.net
--------------------
I fertoll@net.hr I
--------------------
|
|
|
|
|
10 days huh? I wish I was given 10 days to finish some of the jobs I have to do at work!
By the looks of this forum lately it seems that many people are doing the same (or similar) assignment.
The answer you seek is in the answer threads of other posts.
Have a look around
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once 
|
|
|
|
|
Steve Pullan wrote: The answer you seek is in the answer threads of other posts.
Have a look around
well is it that hard to tell the name of post...
nm...
thanks allot
FeRtoll Software.net
--------------------
I fertoll@net.hr I
--------------------
|
|
|
|
|
FeRtoll wrote: well is it that hard to tell the name of post...
nm...
thanks allot
Well is it THAT hard to actually look up and down the topic lists?
They are right there staring you in the face.
...Steve
quod erat demonstrandum
"Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." (Translation: I'll show you the way, but not write the code for you.) I read that somewhere once 
|
|
|
|
|
can u please tell me...
i think that you are wrong, you didnt understand!!!
FeRtoll Software.net
--------------------
I fertoll@net.hr I
--------------------
|
|
|
|
|
Thanks annyway to all.
FeRtoll Software.net
--------------------
I fertoll@net.hr I
--------------------
|
|
|
|
|
I get the following error when I try to update my access table with a datagrid
An unhandled exception of type 'system.invalidoperation" occured in system.data.dll'
The code I am using looks like this:
If CODE_DataSet.HasChanges Then
Dim CON As New OleDbConnection(CONNECT_STRING)
Dim MY_SQL As String
Dim CMD As OleDbCommand
Dim DR As OleDbDataReader
Dim data_adapter As OleDbDataAdapter
Dim command_builder As OleDbCommandBuilder
Dim select_string As String = "SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN;"
CMD = New OleDbCommand(select_string, CON)
data_adapter = New OleDbDataAdapter(select_string, CONNECT_STRING)
data_adapter.TableMappings.Add("Table", CODE_TABLE)
command_builder = New OleDbCommandBuilder(data_adapter)
command_builder.GetUpdateCommand()
data_adapter.Update(CODE_DataSet)
End If
Any ideas? is there a better way to upgrade my MSAccess tables from a datagrid?

|
|
|
|
|
put those on start of class:
Dim CON As New OleDbConnection(CONNECT_STRING)
Dim MY_SQL As String
Dim CMD As OleDbCommand
Dim DR As OleDbDataReader
Dim data_adapter As OleDbDataAdapter
Dim command_builder As OleDbCommandBuilder
what for is this one?
<blink><font color=#FF0000>Dim select_string As String = "SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN;"</font></blink>
you should put that in MY_SQL string up there:
Dim MY_SQL As String="SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN<blink><font color=#FF0000>;</font></blink>" 'And without this one!!! i think...
The third part:
Cmd = New OleDbCommand(MY_SQL, CON)
data_adapter = New OleDbDataAdapter(select_string, CONNECT_STRING)
data_adapter.TableMappings.Add("Table", <blink><font color=#FF0000>CODE_TABLE</font></blink>)
command_builder = New OleDbCommandBuilder(data_adapter)
command_builder.GetUpdateCommand()
data_adapter.Update(CODE_DataSet)
End If
<blink>And i dont see annywhere that u have defined the "CODE_TABLE" variable.
I think i have helped you... Good luck
FeRtoll Software.net
--------------------
I fertoll@net.hr I
--------------------
|
|
|
|
|
In your TMP_ADMIN table, do you have a primary key field? Are you returning that field in your SELECT statement? If not, you'll have to make one to use it with a DataAdapter.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I adjusted the Tmp_Admin table and set quote_line_no to the primary key and am now getting this error. Any Ideas
An unhandled exception of type 'System.Data.DBConcurrencyException' occurred in system.data.dll
Additional information: Concurrency violation: the UpdateCommand affected 0 records.
|
|
|
|
|
I ran into that once before. I can't remember what I did to cause it though...
Hmmmm....Well, let's start with cleaning up your code a bit:
If CODE_DataSet.HasChanges Then
Dim select_string As String = "SELECT TMP_ADMIN.QUOTE_LINE_NO, TMP_ADMIN.OPTION, " & _
"TMP_ADMIN.PRODUCT_CODE, TMP_ADMIN.DESCRIPTION, TMP_ADMIN.QTY, TMP_ADMIN.UNIT_COST, " & _
"TMP_ADMIN.SELL, TMP_ADMIN.TAG FROM TMP_ADMIN;"
Dim data_adapter As New OleDbDataAdapter(select_string, CONNECT_STRING)
Dim command_builder As New OleDbCommandBuilder(data_adapter)
data_adapter.TableMappings.Add("Table", CODE_TABLE)
data_adapter.Update(CODE_DataSet)
CODE_DataSet.Clear()
data_adapter.Fill(CODE_DataSet)
End If
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
THANKS
THAT WORKED GREAT!!
I APPRECIATE THE HELP!!

|
|
|
|
|
No problem!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am using a treeview/listview combination. I want to use the treeview selection to populate what appears in the listview. As an additional note, the treeview will either display a list of companies or trades based on a radio button control.
Does anyone have a suggestion as to which event I should use to accomplish this?
I have tried the following;
AfterSelect event - the event appears to kickoff twice - once for the item that it is deselecting and one for the item it is selecting. When switching radio buttons, the event seems to run for each previous item in the list.
BeforeSelect event - does not know which node is selected
Click event - shows me the the last node selected
Any assistance is appreciated - Thank you in advance.
|
|
|
|
|
I just wanted to update this post in case anyone hapens to run across it.
When doing a treeview.nodes.clear - the afterselect event is actually kicking off for each previous node in the tree. Therefore if you are at node 1000 and you do a clear - the afterselect event kicks off that many times. To resolve the issue - you set the selectednode = nothing . . . see below for example.
If rdoByTrade.Checked Then
'Clear Listview
ListView1.Items.Clear()
ListView1.Columns.Clear()
TreeView1.SelectedNode = Nothing
TreeView1.Nodes.Clear()
'Load Treeview
LoadTree()
End If
In the afterselect event - I only process if treeview.selectednode.text <> nothing.
If TreeView1.SelectedNode.Text <> Nothing Then
LoadListView()
End If
|
|
|
|
|
I have written a small utility which works perfectly fine when it is launched from my local hard disk, but if it is run from a network location, it immediately throws the following error:
Common Language Runtime Debugging Services
Process id=0xd74 (3444), Thread id=0xcb8 (3256)
Click OK to terminate the application
Click CANCEL to debug the application
As a VB.NET newbie, I don't know how to catch this - or even better - make it run from the network location.
Any advice is really appreciated.
|
|
|
|
|
One of the things that you can do is adjust the security settings in the client computer.
In Administrative tools\Microsoft .Net Framework 1.1 Configuration and adjust the Local Intranet Zone Security.
Hope it helps
|
|
|
|
|
Hi All,
I'm generating a fileName based on the current date/time and would like to simply prepend leading zeros to the month, day, hours, minutes, and seconds if they're less than 10. This seems so simple and yet I haven't seen a function to do it (in VBScript).
Of course, I could write my own, but I'd rather not if MS provided one that I've just missed. Do any of you know if this already exists?
In VB6, I would just write something like:
strFinal = Format( nNum, "00" )
In C/C++, something like:
sprintf( strFinal, "%02d", nNum );
(Please forgive any synatx errors...it's been a while since I wrote C )
Any help is greatly appreciated.
Thanks!
Justin
|
|
|
|
|
Yeah, VBScripts formatting leaves much to be desired. But, there is a very easy solution to the problem.
Function FLZ(length, number)
Dim temp
' Generate a string of zeros the length we need, then append the number
' length = 5 and number = 232 would be "00000232"
temp = String( length, "0" ) & number
' Grab the length of the string we need to return
' length = 5 would return "00232"
FLZ = Right( temp, length )
End Function
Now all you have to do is call this for each number you want to format:
Filename = FLZ(2, Month) & FLZ(2, Day) & "-" & FLZ(2, Hour) & FLZ(2, Minute) & FLZ(2, Second)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks, Dave! That works perfectly and you saved me the hassle (albeit minor ) of writing it myself. Much appreciated.
|
|
|
|