|
Whenever any form is opened in your application, check if it is there in the list of recent items. If not found, add it.
|
|
|
|
|
hi everybody
i really need you guys to help me on it, i'm new to VBA know nuts about it.
currently i'm doing a project using excel and macro.
For example i got a spreadsheet which acts like a data its something like this
Site service package price
A 1 78
A 1 78
A 2 128
B 3 175
B 1 78
C 3 175
C 2 128
then from another spreadsheet there is a button to generate them to
Site Total service Total sales
A 3 284
B 2 253
C 2 303
So how do you loop through the spreadsheet and become something like this??
besides that how do you run the form(created in VBA) when u click on one of the button you created?
Thanks
Veon
|
|
|
|
|
To answer the second question first, write a macro to do the job, then insert a button, assign the macro to the button.
Assuming you are running Excel in Office 2007, you click Insert, Shapes, [A Shape of your choice], Draw the shape where you want it to be, Right Click, Assign Macro.
As to the macro itself, I need to have a think and will come back to you, but it is fairly simple I think.
------------------------------------
"When Belly Full, Chin Hit Chest"
Confucius 502BC
|
|
|
|
|
hi thanks for reply =)
just that i want a button that i created, and when it is being clicked it would run the Userform that i have created in VBA. its Userform not spreadsheet
so sorry
thanks
veon
|
|
|
|
|
Design the button you require, save it (as a gif say), then Insert Picture and assign a macro to the picture.
The macro would be...
Sub Macro1
Form1.Show
End
Where Form1 was your form to call.
------------------------------------
"When Belly Full, Chin Hit Chest"
Confucius 502BC
|
|
|
|
|
Where can I find documentation about the byte() from RegionData.data. Specifically I am trying to figure out how to get a path from it. The regions I will be creating will have several polygons. I want to use the Region manipulation functions (Union, Exclude, etc.) and then create a path from the resulting RegionData.data.
|
|
|
|
|
I have never used RegionData.Data, but I found some stuff via google[^]. And
here[^] is microsoft's documentation.
|
|
|
|
|
I was looking to try to use the Region class to do some boolean operations on polygons too, not so much for graphics, but for other purposes.
Anyway, I managed to decode the RegionData structure enough to find out that it does not seem to give the resultant set of points after the operation that we are looking for. Essentially, all it appears to contain is the starting region and a record of the operations you have performed. I'm sure there's something buried in GDI+ that actually applies the operations, but I don't think RegionData is it.
For me, it is back to the drawing board.
|
|
|
|
|
I have an Isometric grid that gets drawn to a bitmap bigger then the screen, then the section of it that has been scrolled to is drawn. How can I figure out where on the grid the user clicked? Should I create an invisible normal square grid over the isometric one? It wouldn't perfect but it might work. Please help
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
I would have expected you to track the scroll position and the x/y coords of the mouse click to track where the user is in relation to the grid. I wonder if the scroll an absolute or is it diffetent for different resolution monitors?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thats basically what I'm doing but its an isometric grid (diamonds, not squares) so it isn't quite perfect.
Have you tried the Krypton Toolkit? http://www.componentfactory.com/free-windows-forms-controls.php
|
|
|
|
|
Hi I have Visual Studio 2008 installed and I am working on a Windows Form with a menu.
I have builded all the elements of menu File...View ..Edit and also added shortcuts.
Everything seems fine on Ddesign View but when I build -run project I can see only the menu without shortcuts.What's going on??
BR
|
|
|
|
|
If by shortcut, you mean the underlined letter in each menu item, hold down the <Alt> key.
Otherwise, the MenuItems have a ShowShortcutKeys property, set it to true
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I tried with ALT and the property ShowShortcutKeys is set to true but the result is the same.
BR
|
|
|
|
|
Did you put an "&" character in front of the character that you're using as the shortcut key??
|
|
|
|
|
I have an application in which i create a thread to run a certain process.
There is a api function call in the thread that tries to connect through TCP/IP to a device and get some data from it.If the device is disconnected then I get a socket exception.
I need to handle this exception however I found out during debugging that even though the exception was thrown,it went unhandled even though I put a try catch block.
However when i run it on the Main UI thread everything is fine.
After doing some searches on this issue I have understood that general exceptions cannot be handled in threads?Is this correct?
If so,is there a way to handle this socket exception?If any one has any idea about this or can direct me to any good articles on this...really appreciate it..
|
|
|
|
|
Hi,
I would guess you tried and did something to the GUI inside the catch block, violating the "only main/GUI thread should ever touch any Control" rule, which causes another exception and that one does no longer get caught by your try-catch since you are already in the catch block.
Experiment with Console.WriteLine() or some file operation to confirm my theory, then start using the Control.InvokeRequired/Control.Invoke pattern.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I didnt understand exactly what you mean..
This is how I am doing it the threading way.
Public Sub somfunction()
'''I make all the thread declarations (address of startthread)
Thread.start()
End Sub
Public Sub startthread
Try
''''APi function call to connect to device --this throws a socket exception when the device is not available but i cannot catch this exception.It throws the exception but it doesn't go to the catch block.
catch ex as exception
End try
End sub
But when I do it on the main thread (on the form)
Public sub somfunction
Try
''API function call----this socket exception is caught
Catch ex as exception
End try
End Sub
End Sub
|
|
|
|
|
The idea of a try-catch construct is you put some code in the try block AND some code in the catch block; an empty catch block is a deadly sin, it is worse than no try-catch at all: it swallows the exception and doesn't do anything with it. At least log it somewhere, say Console.WriteLine(ex.ToString()) so you will notice if and when it occurs.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Did you put the exception handler inside the method running on the thread or in the method that started the thread? In general, if an exception occurs on a background thread and that thread does not handle the exception, the thread dies and no notification is made to the main program.
Option A (do this)
Private Sub ThreadRunMethod()
Try
'your code here that throws an exception
Catch ex as Exception
'something that handles the exception, but
'does not modify the UI directly.
End Try
End Sub
Private Sub OtherMethod()
Dim myThread as New Thread(AddressOf ThreadRunMethod)
myThread.Start()
End Sub
Option B (don't do this, the start method will return right away)
Private Sub ThreadRunMethod()
'your code here that throws an exception
End Sub
Private Sub OtherMethod()
Dim myThread as New Thread(AddressOf ThreadRunMethod)
Try
myThread.Start()
Catch ex As Exception
'handle exception from thread method
End Try
End Sub
|
|
|
|
|
Thanks guys I will try your way and see what happens.
Sorry Luc but I had forgot to mention in the example,I have put a error log entry that writes to a text file in the catch block,but the thing is when the exception is thrown it never goes to the catch block.The thread then just dies.I never know that the socket exception occurred.
I can only seem to catch the Thread Abort Exception in the thread.I am not sure but I had read this article somewhere on the net that only Thread Abort Exception can be handled in background threads.Thought you guys could give me more info on this.
|
|
|
|
|
Hello everybody,
maybe here's someone around who can help end the vicious circle I'm stuck in...
I'm writing a helper class for Outlook in VB2008 Express. The class checks if an Outlook MailItem is an inquiry (following a standardized pattern) or not, and exposes a few methods and properties to be used in VBA. Everything worked fine as long as I didn't try to structure the exposed information, i.e. as long as I held all the fields derived from a mail in the main class's properties.
Then I tried to structure the fields into different classes like "ProductInfo", "CustomerInfo" etc with their relevant methods/properties, additionally placing each of these sister classes into a property of the main class. As a result I could (after regasm, setting the reference in Outlook etc.) see all the classes and their methods/properties in the object catalog of Outlook VBA - and when writing the VBA code, everything seems to be ok and even IntelliSense works, including the hierarchy. So when I type 'Inquiry' and a dot, the nethods and properties of the main class show, typing 'Inquiry.Client." the properties of the client-class show.
And then? At runtime, the sister classes throw an error (object variable not set)...
'(VBA Code)
Public Sub Examine()
Dim Item As MailItem
For Each Item In Application.ActiveExplorer.Selection
Dim Inq As MSInquiryNET.Inquiry
Set Inq = New MSInquiryNET.Inquiry
'Kontrolle ob Kunden-Daten in der Auswahl enthalten sind
Set Inq.Item = Item
Inq.CheckItem Item <--- WORKS (method of main class)
MsgBox Inq.Medium <--- WORKS (property of main class)
MsgBox Inq.Client.FirstName & " " & Inq.Client.FamilyName <---- ERROR
Set Inq = Nothing
Next
End Sub Can anyone tell me what I would have to change in order to avoid that error?
Here's my .NET code (abbreviated):
<Runtime.InteropServices.ComVisible(True)> _
<Microsoft.VisualBasic.ComClass()> _
Public Class Inquiry
Public Function CheckItem(ByVal oMsg As Outlook.MailItem) As Boolean
Me.Medium = GetMedia(oMsg)
Me.Item = oMsg
Try
Select Case Me.Medium
Case "PaperAds"
CollectScoutDataHTML()
Case Else
MessageBox.Show(String.Format("Die Abfrage für '{0}' ist noch nicht automatisiert möglich.", Me.Medium), "Abbruch", MessageBoxButtons.OK)
Return False
End Select
Return True
Catch ex As System.Exception
MsgBox(String.Format("Fehler in der Routine '{0}'", "CheckItem"))
End Try
End Function
' main class' properties
Private _Client As Client
Public Property Client() As Client
Get
Return _Client
End Get
Set(ByVal value As Client)
_Client = value
End Set
End Property
Private _Item As MailItem
Public Property Item() As MailItem
Get
Return _Item
End Get
Set(ByVal obj As MailItem)
_Item = obj
End Set
End Property
End class
<Runtime.InteropServices.ComVisible(True)> _
<Microsoft.VisualBasic.ComClass()> _
Public Class Client
Private _FirstName As String
Public Property FirstName() As String
Get
Return _FirstName
End Get
Set(ByVal value As String)
_FirstName = value
End Set
End Property
Private _FamilyName As String
Public Property FamilyName() As String
Get
Return _FamilyName
End Get
Set(ByVal value As String)
_FamilyName = value
End Set
End Property
End class I assume that I have to set an object for the sister classes somewhere in the .NET code, but by now my attempts failed. Where and how would I declare and expose such an object properly?
Thank you for advice,
Michael
|
|
|
|
|
Too bad that I can't vote for myself coz' I solved the issue by simply adding a new-constructor to the main class, instantiating the sister classes:
Public Sub New()
Me.Client = New Client
End Sub
Of course I'd still be interested in constructive criticism regarding the rest of my approach.
Thank you
Michael
|
|
|
|
|
Hi,
I have created an application using VB6. I want to limit my exe to get install only via my installer. When i install my application an exe is placed in system, if some one copy that exe and paste it in other computer, he can also use the same exe to run application and use. So if there is any way so that i can limit my installation to that particular PC where i have installed it using Installer.
Regards,
Kaushal Arora
modified on Wednesday, July 15, 2009 9:26 AM
|
|
|
|
|
1st Help is not very descriptive of your problem, as everyone posting here is in need of some help.
2nd VB6? Why? It's obsolete by at least 7 years.
3rd You perhaps should look at a system of registration for example, taking some data from the PC and generate an ID that can be used to generate an activation key.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|