|
Like was said before:
AddHandler newButton.Click, AddressOf myButtonClickHandler
but change myButtonClickHandler to the name of the method you want to be called onClick.
Edit:
pseudo code:
if button.text == string1 then
AddHandler newButton.Click, AddressOf myButtonClickHandler1
else if button.text == string2 then
AddHandler newButton.Click, AddressOf myButtonClickHandler2
etc etc
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Then you have to cast the Sender object back to a button. You can then use it just like it was dropped on the form in the designer:
Dim b As Button = DirectCast(sender, Button)
|
|
|
|
|
Hi,
I need some help with a VBA script in Excel 2003, its probably really simple but the macro recorder hasnt been much use and im not sure how to start.
All I want to do is:
Check a worksheet value (i.e. in call A1), for the first value check on another worksheet list
>> If this value is in a row, delete this row and all rows containing this value, if not, do nothing and check the next record
Then move onto the next record (i.e. in cell C2) until there are no records left to check
How would I do this please (or can you give me advise on how to do something similar so I can make a start at finding a solution?).
Many thanks in advance
|
|
|
|
|
I won't write code for exactly what you need but I have got similar example.
Sub CheckList()
Sheet1.Cells(1, 1) = "Text1"
Sheet2.Cells(1, 1) = "Text1"
Dim sValueFromSheet1 As String
Dim sValueFromSheet2 As String
sValueFromSheet1 = Sheet1.Cells(1, 1)
sValueFromSheet2 = Sheet2.Cells(1, 1)
If sValueFromSheet1 = sValueFromSheet2 Then
Sheet1.Activate
Rows("1:1").Select
Selection.Delete Shift
Range("A1").Select
End If
End Sub
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Is there a way to read a datatable from an .xml file on disk such that the created datatable contains only a subset of the records in the .xml table? Something simlar to the select statement in SQL? Certainly seems like there should be, but I can't seem to find it.
Thanks
|
|
|
|
|
cstrader232 wrote: Is there a way to read a datatable from an .xml file on disk such that the created datatable contains only a subset of the records in the .xml table? Something simlar to the select statement in SQL? Certainly seems like there should be, but I can't seem to find it.
You can't find it because it doesn't exist. The DataTable/DataSet objects load the entire XML file. You don't have the option of selecting just the records you want. You'd have to write you own implementation of this, probably based on using an XmlReader, and build the datatable yourself. Implementing a query language would be the hardest part of doing this.
|
|
|
|
|
Thank you... I guess I should save these tables in a database.
Would you be willing to look at my question on reflection that i posted on May 7th?
|
|
|
|
|
cstrader232 wrote: Would you be willing to look at my question on reflection that i posted on May 7th?
I already am, in what little free time I have.
|
|
|
|
|
Hi,
I know this may not be the place to post this, but it is about syntax in VB, so I thought it would be the best place.
(P.s. This is a VERY simplified example of what I want to do... I wouldnt waste effort with linq on something this simple )
I have a list of structures in VB, and can easily select an item from the list:
Public Structure UserInfo
Public ID As Integer
Public Name As String
End Structure
Dim Users As New List(Of UserInfo)
Users.Add(New UserInfo With {.ID = 1, .Name="Jim"})
Users.Add(New UserInfo With {.ID = 2, .Name="Bob"})
Users.Add(New UserInfo With {.ID = 3, .Name="Sue"})
Now, what I want to do is update user ID 3 (for example) to change the name from Sue to Susan...
At the moment I use this:
Dim User As UserInfo = (From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First
Users.Remove(User)
User.Name = "Susan"
Users.Add(User)
This works, but surely there is a better way? I have tried rooting through Google, but I am not sure of what I should be looking for to filter out all the Linq to sql and c# examples
Please help!
|
|
|
|
|
A structure should generally be immutable, and the point of using a structure is mostly defated as you have a reference type inside it. Use a class instead of a structure.
Public Class UserInfo
Public ID As Integer
Public Name As String
End Structure
Dim Users As New List(Of UserInfo)
Users.Add(New UserInfo With {.ID = 1, .Name="Jim"})
Users.Add(New UserInfo With {.ID = 2, .Name="Bob"})
Users.Add(New UserInfo With {.ID = 3, .Name="Sue"})
Now you don't have to remove and add the item to update it:
(From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for the reply - some very useful information in there. I do have one small problem though - I cant find the correct syntax for the update:
(From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
It doesnt work on its own in VB 2k8, and after hours of net searching, I cant find the answer . Using:
dim b as boolean = (From UserInfo In Users Where UserInfo.ID = 3 Select UserInfo).First.Name = "Susan"
compiles, but obviously doesnt update anything (the expression above supposedly returns a boolean)
If you get chance, and you know the answer, can you post a quick message telling me...
Ta muchly!
|
|
|
|
|
I thought that the LINQ expression could be used as an expression, but obviusly it can't. If you put the result in a variable, it works:
Dim user As UserInfo = (From u In Users Where u.ID = 3 Select u).First
user.Name = "Susan"
Another way to do this (and more effective as it only looks until it finds the first occurance) is to use a lambda expression:
Users.Find(Function(u) u.ID = 3).Name = "Susan"
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guffa,
Thanks for that - you have been a huge help!
I cant believe I didnt try option 1 first though I think I tried everything but!
|
|
|
|
|
hi
in may project i exploit my data to exl sheet but the styel not very will because the size of the sill is smailer than data size
is their is way to make the sill size larger in my code not from the excel?
|
|
|
|
|
asha_s wrote: in may project i exploit my data to exl sheet but the styel not very will because the size of the sill is smailer than data size
It's "export my data", not "exploit".
asha_s wrote: but the styel not very will
Are you saying that the cell formatting isn't correct??
asha_s wrote: the size of the sill is smailer than data size
Are you saying the size of the CELL, not "sill", is too small to fit the width of the data?
asha_s wrote: is their is way to make the sill size larger in my code not from the excel
You can't do it in your file, but you can use the Excel object model to do this. You would need either the Visual Studio Tools for Office (recommended) or add a reference to the Excel x.x Object Model. This method requires that you have a good working knowledge of Excel and it's object model to do this.
|
|
|
|
|
Hi,
I was wondering, is there any way to execute code [a procedure, for example] at a specified system time [say 11:45:30] without having to use a timer to check system time every x seconds?
Thanks !
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
Ariel Kazeed wrote: without having to use a timer to check system time every x seconds?
Well, you could use the task scheduler in windows to run your app. If you use a timer, you can set it to first check every 12 hours, then every 8, etc, you can make the timer smaller as the interval to go is less.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello every one...
I just came across a property of picture box called initialimage... when i read the description it says "Image to be displayed while another image is loding"
I had a issue that when i am getting a image to be displayed from DB it is taking lot of time delay...
I taught may be by this property i can load a image saying "Loading Image.... " or something like that... that will make the application a lot more presentable...
But i am not able to use it
Can some one please help me with it
Regards
Nishkarsh
|
|
|
|
|
The property is just an image, so you'd load an image from the file system or resources and set that property. You can probalby also browse direct to an image on the file system in your designer and it will take care of it for you.
Where are you stuck ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I think the way i am doing the application is not proper...
what i am doing is...
form load
{ Get image from DB as byte stream
load the byte stream in the picture box
}
The application is not completing the form load till the image is not loaded... so the form is also not displayed properly...
So even the initialImage will not also been shown...
Is there any other way... may be initiate a thread or something to get the image from DB and load it in picture box...???
Regards
Nishkarsh
|
|
|
|
|
The initialimage should not come from your DB, but from your resources.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
the initialidate image is not coming from Db
What i want to do is... show the initialimage till it lodes the actual image from DB so the delay dose not looks bad...
|
|
|
|
|
The initial image isn't showing up because the drawing of the Form (in Form_Load) hasn't completed, but the UI thread is now blocked running your database code retrieving an image. Since the UI thread is blocked, it can't process any of the WM_PAINT messages for the form or it's controls, and hence, you won't see the initial image.
Just remember, any code running in Form_Load runs before the form is painted.
|
|
|
|
|
Are you getting the image from a database and then assigning it to pictureBox.image?
I assume (but am not certain) that if you use PictureBox::Load(string Url) this is when an initialImage is displayed. If you are not loading and just retreiving the image from a database and then assigning it to a PictureBox.Image (using PictureBox.Image = dbImage) then whilst you are retreiving the image the image is not really loading.
If this is not the case then search MSDN it will tell you a lot more than I can.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Add you initial image to your project resources. Then set the initialImage property to the image from the resources.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|