|
can anybody tell me how to get value of a textbox of form1.vb into textbox of form2.vb in Vb.net.
ex :
I have two forms form1.vb and form2.vb
both are having one textbox each
then i put some value into textbox of form1.vb
and then I load form2.vb and into that loading event I added
Form2_load()
form2.textbox1.text = form1.textbox1.text
end sub
plz tell me how to do that.
--waiting for a quick reply
Aakash
|
|
|
|
|
drmzunlimited,
Keep in mind there are many ways to do this. When I did this I created two forms, a textbox on each and a button on form1 to invoke this action, the click event of the button looks like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String
Dim b As Form2
b = New Form2()
a = Me.TextBox1.Text.ToString
b.TextBox1.Text = a.ToString
b.Show()
End Sub
Nick Parker
The greatest lesson in life is to know that even fools are right sometimes. - Winston Churchill
|
|
|
|
|
Ok, I have searched and searched everywhere and can find nothing. I am trying to implement my own Collection Classes. However, no matter what I try, I cannot get the "For..Each..Next" syntax to work. Evertime it tries to access it (For Each User in UsersCollection), it gives me an 'System.InvalidCastException' error.
Aside from creating Strongly Typed Collection Classes, does anyone know how this can be implemented?
|
|
|
|
|
Tim McCurdy wrote:
it tries to access it (For Each User in UsersCollection), it gives me an 'System.InvalidCastException' error.
Does your class implement IEnumerable Interface? What is wrong with using an ArrayList object?
Nick Parker
The greatest lesson in life is to know that even fools are right sometimes. - Winston Churchill
|
|
|
|
|
Hello again,
C has a function called 'strpbrk,' which stands for string point break. The function takes two arguments. First arg is the string I want to search. The second arg is a string of characters that I want to check for. If any of the characters contained in the second string are in the first string the function returns a pointer to the element in the array where the character was located.
Basically, if none of the characters in the second set are found in the first set, the function returns NULL (or zero, if you will).
Does VB have a function that performs this same operation?
my func:
[source]
' forgive my C-speak
if strpbrk( "HELP ME, PLEASE!", " SXPT" )
//character ' ' found (space)
// do something
printf("Characters found in set!");
else
//characters in second set NOT found in first set
// do something else
printf("Characters NOT found in set!");
[/source]
or
Do I have to use an array and scroll through the entire array to accomplish this?
Thanks in advance,
Like2Byte
|
|
|
|
|
|
Thanks,
here's what I did.
dim c as string
dim s as string
dim i as long
s = "really long string really long string really long string..."
for i = 1 to len(s)
c = mid$(s, i, 1)
select case asc(c)
case 1 to 127
' do stuff
end case
next
|
|
|
|
|
If you're using VB.NET, you can use the IndexOfAny method of the String :
C#:
string s1 = "HELP ME, PLEASE!";
string s2 = " SXPT";
int i = s1.IndexOfAny(s2.ToCharArray());
if (i == -1)
Console.WriteLine("Characters not found!");
else
Console.WriteLine("Characters found at position {0}", i);
VB.NET:
Dim s1 As String = "HELP ME, PLEASE!"
Dim s2 As String = " SXPT"
Dim i As Integer = s1.IndexOfAny(s2.ToCharArray())
If i = -1 Then
Console.WriteLine("Characters not found!")
Else
Console.WriteLine("Characters found at position {0}", i)
End If
In VB6, you would have to fake it:
Dim s1 As String : s1 = "HELP ME, PLEASE!"
Dim s2 As String : s2 = " SXPT"
Dim i As Integer
Dim index As Integer
Dim found As Boolean : found = False
For i = 1 To Len(s2)
index = InStr(1, s1, Mid(s2, i, 1)
If index > 0 Then
found = True
Exit For
End If
Next
If Not found Then
Debug.Print "Characters not found!"
Else
Debug.Print "Characters found at position " & index
End If
|
|
|
|
|
I'm not sure if I made myself clear last time so i'll try to be more succint.
Is it possible to copy a control along with it's code on a excel spreadsheet so that you end up with two or more controls utilising the same code as a foundation, but having different identifiers and operating on different data? Would this require the creation of a macro within visual basic to make a copy of the code within the development environment or is there another way?
Pls help!
|
|
|
|
|
Chris Hooper wrote:
Is it possible to copy a control along with it's code on a excel spreadsheet so that you end up with two or more controls utilising the same code as a foundation, but having different identifiers and operating on different data?
No
Chris Hooper wrote:
Would this require the creation of a macro within visual basic to make a copy of the code within the development environment
Yes
Succint questions, succint answers
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
Are you *sure* about this. Take a quick look at this post on a different board relating to a similar problem. It appears to me that the same code is being used to access multiple controls independently....
http://www.programmersheaven.com/c/MsgBoard/read.asp?Board=2&MsgID=120530&Setting=A9999F0001
|
|
|
|
|
Alright yeah i see your point. Well instead of copying the controls can i simply add them sequentially and do something similar to what the dude is doing with the buttons in the post i have mentioned *phew* ?
|
|
|
|
|
Any has any idea ahy this is crashing on me giving error in the exception "Syntex error in inser into statement" Thank you
The code it:
Try
Dim objCon As OleDbConnection
objCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source =C:\Projects\PDFMerge_Ali\PDF_Merger\pdMerge.mdb;;Persist Security Info=False")
objCon.Open()
'Create an instant of the Adapter
Dim daQueue As New OleDbDataAdapter("Select * From Queue", objCon)
daQueue.MissingSchemaAction = MissingSchemaAction.AddWithKey
Dim dsPubs As New DataSet("Pubs")
daQueue.Fill(dsPubs, "Queue")
MsgBox("data loaded")
' Create a new instance of a DataTable.
Dim tblQueue As DataTable
tblQueue = dsPubs.Tables("Queue")
Dim drCurrent As DataRow
' Obtain a new DataRow object from the DataTable.
drCurrent = tblQueue.NewRow()
' Set the DataRow field values as necessary.
drCurrent("ProfileName") = "test"
drCurrent("ProfileDes") = "test"
drCurrent("FileType") = "test"
drCurrent("Merge") = "yes"
drCurrent("Match") = "test"
drCurrent("Printer") = "test"
drCurrent("StartOnLoad") = "yes"
drCurrent("PrintFiles") = "test"
drCurrent("IncomingDir") = "test"
drCurrent("MergeDir") = "test"
drCurrent("TemDir") = "test"
drCurrent("PrintDir") = "test"
drCurrent("FailDir") = "test"
'Pass that new object into the Add method of the DataTable.Rows collection.
tblQueue.Rows.Add(drCurrent)
MsgBox("Add was successful.")
Dim objCommandBuilder As New OleDbCommandBuilder(daQueue)
daQueue.Update(dsPubs, "Queue")
objCon.Close()
MsgBox("Data Updated")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Zulfikar Ali
|
|
|
|
|
Kindly check datatypes and data & also if the length of the data does not exceed the maximum length.
VIPUL BHATT
|
|
|
|
|
Thank you for your response. I had one yes/no field and i was passing string into it. Solved the problem and thank you again.
Zulfikar Ali
|
|
|
|
|
Does anyone know of a good tool for adding comments into VB .Net? C# I know will produce the XML comments and we are wondering if there is anything out there like that for VB .Net? Also, we may be interested in a Macro to add comment headers to our methods for the developers to fill in. Does anyone know of any good macros out there that are available?
Thanks,
JS
|
|
|
|
|
JS,
I had a similar problem and wrote a VS addin to try and address this. It can be found at http://ncomment.sourceforge.net/[^]
It is still in Beta, my apologies if you find any bugs in it. Let me know what you think. I am also working on a macro to add comment blocks to the top of functions.
Ben.
|
|
|
|
|
Hi,
Thanks for looking.
I'm trying to determine how to change the background color of a textbox when the focus is given to a textbox.
Changing the color is easy. How do I determine who has the focus so I can change the color?
Can someone help me?
Thanks.
|
|
|
|
|
Opps, sorry. Stealing bandwidth here.
Here's what I found...
Double click in the control.
Delete the function the IDE creates.
Select the "GotFocus" command in the right hand drophand list box in the IDE.
A new function will appear.
Type in:
ctrlName.BackColor = {{valid color code}}
Thanks anyway.
|
|
|
|
|
|
Anybody know what runtime error 8577, "could not link" is all about? Basically I'm using crappy data reports to display info from a database but sometimes I get a blank report (even the print buttons aren't there, everything is white). I have made an menu item which refreshes the report when clicked and hey presto my report shows up. However, when I try to refresh straight after I show the report, I get that error 8577. Its a strange problem to do with data reports and, in my opinion shows just how rubbish vb 6.0 is.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
I am fairly new to VB programming so I don't know if the following is possible and I would appreciate some thoughts.
I have written a combo box control for Excel which allows the user to select rows of data in a different sheet and have the pasted into the one containing the control.
My next objective is to create buttons controls to introduce these combo box controls to the spread sheet sequentially. So for example, if you pressed button 1 a copy of combobox1 would appear in the worksheet. If you then pressed button 2 a copy of combobox2 would appear following. My problem with copying and pasting so far is that the code associated with the comboboxes is not copied along with the GUI of the control. Is it possible to produce multiple instances of the same control, utilising the same code but have them seperated so that they can all perform their functions independently, on different parts of the worksheet. The user must be able to select the number and order of the combobox controls within the worksheet.
I thought of producing a macro which copied the code within the visual basic window but this would lead to conflicts since every instance of the combobox control would share the same identifier (eg. combobox1). Would this mean that each instance of the control would be trying to work on the same data?
Any thoughts would be appreciated.
Many thanks,
Chris.
|
|
|
|
|
Anyone know how to print a .doc file? I am printing it using Print Document but gets ugly in the beginning. It prints all kinds of symbols first. Anyway please help if you know the fix. Thank you.
Zulfikar Ali
|
|
|
|
|
I figured it out!
Zulfikar Ali
|
|
|
|
|
Brightneon game company is looking for more free visual basic programmers to continue to build a game engine.
If you were expecting a paying job sorry, but any small time effort in doing some code will be appreciated.
Things are negotiable.
http://www.brightneon.com/game_engine/index.html
|
|
|
|