|
VB also has the bit shift operators - the main adjustment for this code snippet is due to VB not allowing inline assignments:
K1 = K1 << 4 Or K0
Data = K1
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
Hello everybody,
in my application (.NET 2.0) I use plugins for different tasks and want to pass events between the plugins as well as with the MDI window. The basic idea of the following code setup works: after starting the app, the handler is added and the event is raised through the interface and the plugins 'Process()' routine, resulting in the trace-line which has been defined in the main app's corresponding Sub (pluginInfo_ButtonClicked).
The funny thing is that, when raised with exactly the same command in the button.click event of the plugin, the event isn't heard from the main app anymore - no trace-line written. The event handler should still be there, at least I didn't purposely remove it.
I don't yet fully understand everything around events, so I might just miss something out. Could anyone please have a look and tell me where I'm going wrong?
Thank you
Michael
' ... the Interface
Public Interface IPluginInfo
Event MyButtonClicked As EventHandler
Sub Process()
ReadOnly Property Name() As String
End Interface
' ... the MDI Application
Public Class MainAppPluginhandler
Private pluginInfo As IPluginInfo
Public Sub New()
(...creating an instance of IPluginInfo here)
Try
AddHandler pluginInfo.MyButtonClicked, AddressOf pluginInfo_ButtonClicked
Trace.WriteLine(String.Format("+ Handler for PlugIn {0} installed in MDIForm.", pluginInfo.Name))
pluginInfo.Process()
Catch ex As Exception
End Try
End Sub
Private Shared Sub pluginInfo_ButtonClicked(ByVal sender As Object, ByVal e As EventArgs)
Trace.WriteLine("+ Event 'ButtonClicked' received by PlugInHandler!")
End Sub
End Class
' ... and the plugin class
Public Class MyPlugin
Implements IPluginInfo
Public Event MyButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs) Implements IPluginInfo.MyButtonClicked
Private Sub OnMyButtonClicked(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyButton.Click
RaiseEvent MyButtonClicked(Me, Me, EventArgs.Empty)
Trace.WriteLine("+ Event MyButtonClicked raised.")
End Sub
Public Sub Process() Implements IPluginInfo.Process
Trace.WriteLine("+ Function 'Process' started in MyPlugin... wait 2 seconds.")
Thread.Sleep(2000)
Trace.WriteLine("+ Event MyButtonClicked' raised in MyPlugin.")
RaiseEvent MyButtonClicked(Me, EventArgs.Empty)
End Sub
End Class
|
|
|
|
|
hello!
i wanna to know how to match between two images which are same or not?
could u tell me please!
if u can, i'll thank you very much!!!!!!!! 
|
|
|
|
|
Can you explain what you mean by "match"? Do you mean two images that show the same thing or two images that are identical? Do they need to be the same color, same shape, same size?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Use GetPixel for both the Bitmaps and compare it pixel by pixel.
|
|
|
|
|
|
Hello to All,
I have a image which size is (100,100). I am tring to print it works fine.
But i want to know that is it possible to print second half half image.
Thanks
If you can think then I Can.
|
|
|
|
|
This isn't clear. Are you missing half of the image? or do you just want only half of the image? and which half? the right half? the bottom half? the center half?
So please explain, and also show the relevant part of your current code (inside PRE tags!).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I want to print certain area(Selected Area) of an Image.Selected area is in Rectangle.
Thanks For reply
If you can think then I Can.
|
|
|
|
|
So replace your current Graphics.DrawImage() with one of its overloads, allowing to specify exactly which part of the image needs to be drawn.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
My code for storing the data:
If Len(strJnts) > 0 Then
_gblString = CreateGUIDString()
gblConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\JWI\Data\JWI.mdb;Jet OLEDB:Database Password=jWi;")
strData = "INSERT INTO LOLItems (LOLItemsID, LOLIFormID, Type, TextBox, MaterialsID, Units, DateCreated )" _
& " VALUES ('" & _gblString & "', " _
& "'" & _frmGuid & "', '" _
& 1 & "',' " _
& strName & "',' " _
& _MATGuid & "',' " _
& strJnts & "',' " _
& Now() & "');"
gblCMD.Connection = gblConn
gblCMD.CommandText = strData
Dim cmd As New System.Data.SqlClient.SqlCommand
gblConn.Open()
gblCMD.ExecuteNonQuery()
End If
The value of _MATGuid is gathered from the tag property of a label. In the immediate window:
? _MATGuid
"55368562-a5c5-429d-a491-e1bb24f37836"
? strdata
"INSERT INTO LOLItems (LOLItemsID, LOLIFormID, Type, TextBox, MaterialsID, Units, DateCreated ) VALUES ('{6b8da5a3-fbad-4140-af9a-2728a9e35af6}', '{a6a0e519-aa21-48b0-b26a-839caed800c7}', '1',' txtRodE_1',' 55368562-a5c5-429d-a491-e1bb24f37836',' 10',' 6/4/2010 9:47:40 PM');"
In Access the value for MaterialsID for the record ended up being:
{05F3C3FC-D57C-7047-0200-00000000E927} It is a Number field, ReplicationID, Indexed (Duplicates Allowed)
When I saved 14 record at a time I got the following- It seems like they are GUIDS being generated by Access as they are so similiar.
MaterialsID
{05A5C29C-D57C-7047-0500-00000000EA35}
{05A5C29C-D57C-7047-0100-000000009A3E}
{05A5C29C-D57C-7047-0400-000000001A48}
{05A5C29C-D57C-7047-0000-00000000BA28}
{05A5C29C-D57C-7047-0200-000000009A30}
{05A5C29C-D57C-7047-0200-000000009A43}
{05A5C29C-D57C-7047-0400-000000003A34}
{05A5C29C-D57C-7047-0000-00000000DA41}
{05A5C29C-D57C-7047-0300-000000002A45}
{05A5C29C-D57C-7047-0700-000000007A3B}
{05A5C29C-D57C-7047-0300-00000000AA31}
{05A5C29C-D57C-7047-0500-000000009A49}
{05A5C29C-D57C-7047-0600-000000007A39}
{05A5C29C-D57C-7047-0100-00000000BA2C}
The values that the _MatGuid SHOULD have been are shown below:
55368562-a5c5-429d-a491-e1bb24f37836
2fa63b3f-2399-4503-a1a6-91249c21bada
16221dca-6f9b-47ba-a733-b38e4f40ad96
526748be-209d-4cb2-abae-3e9fc6e188d3
aaecd995-dbb9-4bf0-a461-474b4cbe590f
3cf2864b-c1fd-4b46-b588-9c1d89d08eac
d131d5d7-b925-424d-b791-df2a322f0123
d06af1df-3233-495f-bd26-610dd09b1b12
b2b63ef0-42b5-4d80-9bfe-ced762db2e42
b7bbeaef-79d8-4b36-be69-26484f8e4fe5
002f9e90-3b33-4910-b18a-b80930ceb838
442b44fd-0427-433e-9d76-d0b3c79e279c
bbb3eca6-e71e-47b3-866d-b6795166b65f
a7e9f919-92d9-45db-a6c5-de1b7f393381
I don't see where or how it can get changed or corrupted.
Any suggestions greatly appreciated.
Larry
modified on Friday, June 4, 2010 11:26 PM
|
|
|
|
|
First, your values have spaces in them. Second, your GUID in question doesn't have curly brackets around it, possibly making it an invalid GUID. Third, GUIDs are probably overkill for your ID's.
Lastly, do NOT use string concatentation to build your SQL statements. Use parameterized queries instead. The parameter objects will handle correctly formatting your values for you instead of you guessing at what they should be and (cardinal sin here) you using values directly out of textboxes completely unvalidated and unnormalized.
|
|
|
|
|
Not used Access for some years but IIRC Access will generate values for ReplicaID fields.
You should only use this type if you are using replication and have the Replication Manager. As far a I remember without it replication was painful.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
Please!
I need some vb6 code to parse these, especially vhosts.conf. Even vb.net code can help.
Thanks.
|
|
|
|
|
This[^] is the best your going to get. We're in the business of supplying finished code to do things.
|
|
|
|
|
Thanks God I shouldn't pay Google for that.
Listen, I don't say I want it for free!
Are you just in a bad mood?!
|
|
|
|
|
No. It's just you're about the 5 millionth person to show up saying "I want code for ____!".
I believe in writing your own code so you can learn. You're also asking for something that is very rarely ever used. You're not likely to find prewritten code for this.
|
|
|
|
|
what's the vb.Net counterpart of the following blocks in Csharp?
public class NullableDateTimePicker : System.Windows.Forms.DateTimePicker
{
public NullableDateTimePicker() : base()
{
base.Format = DateTimePickerFormat.Custom;
NullValue = " ";
Format = DateTimePickerFormat.Custom;
CustomFormat = "dd MMM yyyy";
this.DataBindings.CollectionChanged += new CollectionChangeEventHandler(DataBindings_CollectionChanged);
}
}
class DateTimePickerEditingControl : NullableDateTimePicker, IDataGridViewEditingControl
{
public DateTimePickerEditingControl()
{
this.Format = DateTimePickerFormat.Custom;
this.CustomFormat = "dd MMM yyyy";
}
}
|
|
|
|
|
You know, that there are tools for conversing code from C# to VB.Net, do you? Just google for them.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Never mind. I was making a small mistake.
In block 1 it should be:
MyBase.New
In block 2 it should be:
class DateTimePickerEditingControl<br />
Inherits NullableDateTimePicker<br />
Implements IDataGridViewEditingControl<br />
End Class
I was writing this in the first place:
class DateTimePickerEditingControl<br />
Inherits NullableDateTimePicker, Implements IDataGridViewEditingControl<br />
End Class
|
|
|
|
|
|
Greetings everyone,
I'm going through Stephen Toub's book "Patterns of Parallel programming" to try and figure out the different tips and tricks of parallel programming.
Besides having found few minor errors in the book already, I'm stuck on the example described on page 71:
Public Const NUM_STEPS As Integer = 1000000
Shared Function ParallelLinqPi() As Double
Dim [step] = 1.0 / CDbl(NUM_STEPS)
Return ParallelEnumerable.Range(0, NUM_STEPS).Select(
Function(i)
Dim x = (i + 0.5) * [step]
Return 4.0 / (1.0 + x * x)
End Function).Sum() * [step]
End Function
The VS underlines this whole chunk of code and explains the following:
"Overload resolution failed because no accessible 'Sum' accepts this number of arguments."
Apparently, the Sum() function at the end needs to have a selector (selector As System.Func(of Object,Double)). There is no mention of this in the book =(
What should I write inside the Sum, to make this example work, any ideas?
Thanks...
Agarwaen
|
|
|
|
|
The code you posted works perfectly in VS 2010. Are you using 2005 or 2008?
|
|
|
|
|
I use VS 2010 and get the error described in my message above. That is why I'm stumped, because according to the book it should work, but it doesn't =(
Perhaps I need to import some specific namespace ? If so plz tell me which one...
|
|
|
|
|
Are you using one of the 2010 Betas? I tried it on the VS2010 RC1 release, just created a new standard Console app, typed the code in and it worked.
The only namespace required is System.Linq .
|
|
|
|