|
Hi Michael,
I don't know what the official answer would be; there may well be a fancy tool or command to solve your problem right away.
However this is what I would do, all very basic, nothing fancy at all; its main purpose is to increase observability and tracability:
- create a log method that somehow logs a one-line message
- make sure try-catch blocks are present where useful
- add log statements to the code, in order to trace progress and report all exceptions
- check that there are no empty catch blocks nor finally blocks
Assuming your allowed to create and write files, a log method could be (not tested in VB!):
Public Shared Sub Log(msg as String)
File.AppendText("<path to a writable location on disk, maybe> C:\temp\mylog.txt", msg & Environment.NewLine)
End Sub
Of course, a more elaborate scheme could be used, with timestamp, thread ID, severity, whatever.
|
|
|
|
|
Thank you Luc for your pragmatic approach.
Following your basic idea, I had already put a MsgBox after every couple of lines before - so I just had to change them a little bit to get the same result as a log. Unfortunately the result is that the corresponding log lines are just not written (like the msgboxes not shown before), while the log lines of the classes' other methods are written. That's also the basis for my assumption that the events aren't fired at all...? In this special case, the Try... Catch approach didn't seem to make sense, as for the test I removed everything but the log lines from the IDTExtensibility-Members just to see if they are called at all.
Is it possible that I encounter a general problem with the IDTExtensibility2 Interface here? Like written in the above mentiones message, I had experimented with stuff I didn't really understand... Would it be possible that I "destroyed" anything in that interface, so that it doesn't provide the events anymore (e.g. registry setting)? If yes: Would I have to re-install VB Express or can I extract the relevant assembly somehow from the installer package?
Thanks again
Michael
|
|
|
|
|
Hi Michael,
I'm not familiar with the IDTExtensibility2 interface, so I can't comment from experience. I did look a bit at the MSDN documentation and this struck me:
"IDTExtensibility2 contains methods that act as events when the interface is implemented. Visual Studio calls these methods whenever an event that affects an add-in occurs, such as when it is loaded or unloaded, whenever a change is made to it, and so forth." from http://msdn.microsoft.com/en-us/library/extensibility.idtextensibility2(VS.80).aspx[^]
Now how would Visual Studio be involved once your component is ready for use??? I think you'll need to Google some more, maybe find a better example, or a completely different angle on the problem.
Good luck!
|
|
|
|
|
Hi Luc,
thank you for you rapid answer and the link, which I had a quick look on.
Somehow the first sentence "IDTExtensibility2 Interface... Hosts the event notifications that occur to add-ins..." makes me think even more that I might have a problem with the interface itself, since there's obviously no event notification happening.
Probably a re-installation of the interface dll (seems like this msaddndr.dll is part of windows itself) helps - but I guess I'll do that tomorrow. Please send me a short STOP if you think that thought is complete nonsense.
In case you're here in Europe, too I wish you a good night - and thanks for the mental support anyway
Michael
|
|
|
|
|
You're welcome.
I would not reinstall anything until I was convinced the approach and code are valid (unless there were other reasons to suspect a couple of things of course).
I would research more, and try on another system. I suggest you also try some totally different code that relies on the same parts, maybe something from here[^].
|
|
|
|
|
Hi Luc,
just to let you know: I don't know how and which, but one of my todays steps solved the issue! After your hint I got a bit into the tracing of VB, which helped here and will help me in the future, too. For this one it's quite likely that it was a registration issue... Thanks again.
|
|
|
|
|
Hi,
i've a 2 sim mobilephone and I have the following problem: I want to create a software (in vb.net or c#) that allows me to assign each number stored in the phonebook with one sim. In this way I could call one vodafone number with my vodafone sim and one number Tim with my Tim sim. Can you help me?
I hope to be clear and have been written correctly in English
|
|
|
|
|
How you do that depends entirely on the phones themselves and if you can get an SDK or whatever you have ot do to communicate with the phones. You're best source of information is going to be the manufacturer of the phones. What you're thinking of doing is VERY specialized and you're not likely to get any help on how to do this from here. You need to find a forum more specific to "hacking" your phone than this one.
|
|
|
|
|
ok, but at least is It easy to know where the register is set to choose the sim for call?
|
|
|
|
|
Only through the SDK documentation on the phone.
I have no experience with it myself, but I at least know where'd I look for the information.
|
|
|
|
|
I have looked for an explanation to why the following code is resulting in the error
"Overload resolution failed because no 'SetSelectedCellCore' is accessible." on the line
dgvStudents.SetSelectedCellCore(0, 0, True)
I have no controls on my form. I am running Win7 and Visual Basic Express 2008, but i get the same result on my WinXP machine running VB Express 2008. Any help would be appreciated.
Imports System.Windows.Forms
Public Class Exercise
Dim dgvStudents As MyDataGridView = New MyDataGridView
Private Sub Exercise_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Text = "Students Records"
dgvStudents = New MyDataGridView()
dgvStudents.Location = New Point(12, 12)
dgvStudents.Size = New Size(650, 100)
Dim colFullName As DataGridViewColumn = New DataGridViewColumn
colFullName.Name = "FullName"
colFullName.HeaderText = "Full Name"
Dim celFullName As DataGridViewCell = New DataGridViewTextBoxCell
colFullName.CellTemplate = celFullName
dgvStudents.Columns.Add(colFullName)
Dim colPhone As DataGridViewColumn = New DataGridViewColumn
colPhone.Name = "PhNum"
colPhone.HeaderText = "Ph Number"
Dim celPhone As DataGridViewCell = New DataGridViewTextBoxCell
colPhone.CellTemplate = celPhone
dgvStudents.Columns.Add(colPhone)
Controls.Add(dgvStudents)
dgvStudents.SetSelectedCellCore(0, 0, True)
End Sub
End Class
Public Class MyDataGridView
Inherits DataGridView
Protected Overrides Sub SetSelectedCellCore( _
ByVal columnIndex As Integer, _
ByVal rowIndex As Integer, _
ByVal selected As Boolean)
MyBase.SetSelectedCellCore(columnIndex, rowIndex, selected)
End Sub
End Class
modified on Wednesday, May 12, 2010 1:46 PM
|
|
|
|
|
The overridden method remains protected and can only be accessed from within your MyDataGridView class. A public wrapper method would be needed to do what you want as the SetSelectedCellCore method's access modifier cannot be changed from protected to public.
Alan.
|
|
|
|
|
This is a protected method which means that you can't access it directly. AFAIK you can only access it from within the class.
Generally, the only time you would want to override this method was if you wanted to prevent a user from focusing on a particular cell.
Why not just do
dgvStudents.Rows(0).Cells(0).Selected = True
I would not suggest overriding a protected method to do something it's not meant to do...but...
you could just add a new method within your MyDataGridView class called something like MySetSelectedCellCore that simply calls your overridden SetSelectedCellCore . Then you just call that MySetSelectedCellCore . It would look like:
Public Class myDataGridView
Inherits DataGridView
Protected Overrides Sub SetSelectedCellCore(ByVal columnIndex As Integer, ByVal rowIndex As Integer, ByVal selected As Boolean)
MyBase.SetSelectedCellCore(columnIndex, rowIndex, selected)
End Sub
Public Sub MySetSelectedCellCore(ByVal columnIndex As Integer, ByVal rowIndex As Integer, ByVal selected As Boolean)
SetSelectedCellCore(columnIndex, rowIndex, selected)
End Sub
End Class
though again, I must stress, that's not what it was intended to do and not the best way to do what it looks like you are trying to do.
|
|
|
|
|
Thanks, both of you, for the pointers. I have learned a couple of different ways to do this now. I should be able to apply this to different objects as well.
|
|
|
|
|
Just as an FYI, when you call
dgvStudents.Rows(0).Cells(0).Selected = True the DataGridView implements this by making a call to SetSelectedCellCore You can see this by using the class you created as listed in your OP and setting a breakpoint on
MyBase.SetSelectedCellCore(columnIndex, rowIndex, selected) then calling
dgvStudents.Rows(0).Cells(0).Selected = True .
|
|
|
|
|
I did notice that, so I went searching for the reason that it worked... I did a little bit of VB6 as a hobby and wondered what could be so drastically different in vb.net. now i need to move a program I wrote in VB6 over to .net. I think I might like the new OOP paradigm, but only time will tell, and there's a little bit of a learning curve here.
|
|
|
|
|
hi
how to parse the Excel worksheet and write the data to a file using VBA Scripting ?
kindly provide me the tutorial to implement this task.
Thanks in Advance,
Narendra
|
|
|
|
|
Here is a snipet of VBA code that loops through a sheet and sets a cell value. (nothing really useful)
What it does show you is how you can loop through cells and get their values.
Hope this helps.
Sub DEMOscript()
'
Dim i As Integer
Dim r As Integer
r = MsgBox("This will clear the contents of Sheet1", vbOKCancel, "Confirm Processing")
If (r = 1) Then
Sheet1.Cells.Clear
totalrows = ActiveSheet.UsedRange.Rows.Count
For i = 2 To totalrows
Sheets("Sheet1").Cells(i, 2).Value = i
Next i
Else
MsgBox ("No processing performed.")
End If
End Sub
|
|
|
|
|
In addition to Davids snippet I would recommend you to use Intellisense as much as you can. It's easy, gives you some inspiration even while typing, and helps flatten your learning curve Let me give you an example:
If MsgBox("This will clear the contents of Sheet1", vbOKCancel, "Confirm Processing") = vbOK then ... instead of the (unnecessary) r variable shows you the possible results of the message box, so that you wouldn't have to guess the value.
|
|
|
|
|
|
How can I search all the files available on my computer (C,D,E,F...) drives like search functionality in windows.
The application should search the subfolder as well in the drives.
I want to have a list of all the files available in my computer.
Thanks In Advance
|
|
|
|
|
That's going to be slooow..
The recipe first;- List all drives (Google for a snippet)
- Create a recursive function to loop all folders in that drive
- Proces all files and folders that the function returns
ejaz_pk wrote: like search functionality in windows.
That one allows you to search "within" files, and is more complex then the recipe above. Do you want to "list" all your files, or do you want to search their contents?
I are Troll
|
|
|
|
|
I just want file names list and path of the files.
|
|
|
|
|
The hardest part would be the recursive funtion to scan the folders. There's an example on that over here[^], and also on the Knowledge Base[^].
The rest is up to you
I are Troll
|
|
|
|
|
Easily done by shelling to a DOS command that creates a text file, then parsing this if necessary:
The following DOS command will create a file called Output.txt with a list of all files (not including system or hidden) on drive c: - the /s recurses subdirectories, and the /b restricts the output to filename only.
DIR C: /s /b >Output.txt
====================================
Transvestites - Roberts in Disguise!
====================================
|
|
|
|