|
for current scenario excel only
|
|
|
|
|
You don't need VBA for this.
Inside your sheet you can use the function 'SUMIF' for this ...
|
|
|
|
|
Hi Team,
I have a existing .xlsm file which I was able to open in older excel versions(like 2010) successfully.
But i am unable to open the same .xlsm file in newer office versions 2016.OPening as blank.
Tried changing the settings under Excel->File->Options->Advanced
Under "General"
->Unchecking the "DDE"
Under "Display :"
->Unchecked the "Disable hardware graphics acceleration"
->Turn off add-ins.
Anyone faced this issue ?
Any help will be really appreciated.
Thanks in advance.
Thanks
Manju
|
|
|
|
|
Does this have anything to do with Visual basic programming?
|
|
|
|
|
As most macros are written in VBA I would assume this is the closest forum, we don't have an Office forum thankfully.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
True, but the question does not mention any macros.
|
|
|
|
|
|
I was asked to sort a list of contacts and said Ok thinking it would be pretty easy using OrderBy in Linq. Then I ran the program and looked at the data and found it more difficult.
The customer decided to make the contact names like this, and I wasn't able to sort the 2nd part
Acme Company - John Doe
Acme Company - Abe Frank
I kept getting the same result of an unordered list using OrderBy(Function(x) x.FCONTACT)
Then Somehow I got side tracked into using Array.Sort, contacts.Sort() and ended up creating this new class with sort helpers that I can't get working.
I think I'm on the right track here, so went down this road to get a better understanding.
I get an intellisense error on Sort, and when I run it I get a Unhandled exception of can't cast to ContactsList in the sortContactAscendingHelper when it reads the single line of code.
contacts.Sort(ContactsList.SortContactAscending())
What have I tried, well this basically. I'm driving down a dark unfamiliar street in the rain on this and can't find much help on the subject.
Public Class ContactsList
Implements IComparable
Public Property FID As String
Public Property FCHECK As Boolean
Public Property FCUSTNO As String
Public Property FCOMPANY As String
Public Property FCONTACT As String
Public Property FEMAIL As String
Public Function CompareTo(obj As Object) As Integer Implements IComparable.CompareTo
Return FCONTACT.CompareTo(obj)
End Function
Public Shared Function SortContactAscending() As IComparer
Return CType(New SortContactAscendingHelper(), IComparer)
End Function
Public Shared Function SortContactDescending() As IComparer
Return CType(New SortContactDescendingHelper(), IComparer)
End Function
Private Class SortContactAscendingHelper : Implements IComparer
Function Compare(ByVal a As Object, ByVal b As Object) As Integer Implements IComparer.Compare
Dim c1 As ContactsList = CType(a, ContactsList)
Dim c2 As ContactsList = CType(b, ContactsList)
Return String.Compare(c1.FCONTACT, c2.FEMAIL)
End Function
End Class
Private Class SortContactDescendingHelper : Implements IComparer
Function Compare(ByVal a As Object, ByVal b As Object) As Integer Implements IComparer.Compare
Dim c1 As ContactsList = CType(a, ContactsList)
Dim c2 As ContactsList = CType(b, ContactsList)
Return String.Compare(c2.FEMAIL, c1.FCONTACT)
End Function
End Class
End Class
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Seems to me you have crappy data which is the root of your problem. Solving it with sort constructs is the wrong way to go. Fix the underlying data issue.
I note your contact list has both company and contact fields but your example has the data as 1 value separated by a dash. If you split the data on the dash (assumes the dash is consistent) then sorting becomes a trivial matter.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I figured everybody has to deal with crappy data. Maybe I should go to the source of the crappy data and fix that as well.
Good advice however.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
Based on some code I found I changed this code to take a picture from a webcam on a regular basis and stores the image an a folder.
This works! But I want to be able to minimize the form and put it in the system tray. When I do that I only get dark images.
Does anyone have a solution for this? I want the form in the system tray as people do other things on this laptop whilst the code takes pictures of a machine every x seconds.
This is the link to the code (in zip file) on OndeDrive:
Webcam VB .net code OneDrive[^]
Thanks for your input.
Frank
|
|
|
|
|
The component that does the capturing needs to paint the stream. Without painting the stream, there's only a black nothing to capture. Unfortunately, it only paints when Windows tells it to, and that's only when it is visible.
A cheap solution is to buy a Raspberry Pi and use that as a dedicated machine for capturing the images.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks Eddy.
Not the answer I wanted to hear, but I will look into a solution when a Pi.
Regards,
Frank
|
|
|
|
|
The below code sets the selected text in the RichTextBox to a protected link.
This works but I have an issue when entering text before the link; particularly
a space char. When I enter a space character before the link, the link loses
it's link state;
1. The color changes to normal text color.
2. The underline disappears.
3. I no longer receive the link click message.
4. It remains protected.
I can type other characters and do not lose the link state except when
the caret is on the space immediately preceding the link.
Test case with this text where link is the formatted link:
" abc link"
Hitting the spacebar anywhere between the 'c' and the 'l' causes the link to lose its state
Hitting any other char does not affect the state except when the char is next to the 'l' and
then it loses its state.
Anyone have an idea of why the link is losing it's attribute?
Thank you
Public Function SetSelectionCharFormat(ByVal hEdit As IntPtr, ByVal cf As CHARFORMAT2, _
Optional ByVal fmt As EMFormatMasks = EMFormatMasks.SCF_SELECTION Or EMFormatMasks.SCF_WORD) As Boolean
Dim bReturn As Boolean = False
' This is test code which overrides the input
cf.dwMask = (CFMMask.CFM_LINK Or CFMMask.CFM_PROTECTED) ' &h20 or &h10
cf.dwEffects = (CFEEffects.CFE_LINK Or CFEEffects.CFE_PROTECTED) ' &h20 or &h10
Try
Dim structPtr As IntPtr
' Allocate the memory for structure data
structPtr = Marshal.AllocHGlobal(Marshal.SizeOf(cf))
' Copy structure data to memory ptr
Marshal.StructureToPtr(cf, structPtr, False)
' Return non-zero if passes; code from winctrl4.cpp
' fmt = the default (EMFormatMasks.SCF_SELECTION Or EMFormatMasks.SCF_WORD)
bReturn = (MyUtilsLib.WindowsAPI.SendMessage(hEdit, EMMessages.EM_SETCHARFORMAT, fmt, structPtr) <> 0)
' Free memory
Marshal.FreeHGlobal(structPtr)
#If DEBUG Then
If bReturn = False Then
Debug.WriteLine("SetSelectionCharFormat() failed")
End If
#End If
Catch ex As Exception
MsgBox(ex.Message())
End Try
Return bReturn
End Function
-- modified 23-Jan-19 15:38pm.
|
|
|
|
|
In a vb.net 2010 application, I have a page_load section of code where I would like to know add extra code unless I need it. Basically if the application is in development or test compile mode, I would like the application to point to a test url. If the application is in production mode, I would like the application to point to a production url.
From the page_load section of code, is there a way to knowwhat mode the applicaiton is in? If so, can yhou show me the code on how to accomplish this goal?
In addition, if the application is in production mode is there a way to not have the development or test logic be accessed by the application? If so, would you show me that logic?
|
|
|
|
|
|
What you supplied to me is a very good option that works! However on my application, there are the build options for:
1-Development,
2-Test, and
3-Production.
Based upon my build options, can I write code the will select only '1-Development' instead of placing #debug in the logic. Or having #debug stand for 1-development? If so, would you should me the code for this?
|
|
|
|
|
Sorry but I do not understand what you mean. The DEBUG define is automatically set by Visual Studio when you do a Debug build, and unset when you do a Release build. You need to decide what you want for a Test build and create the appropriate settings.
|
|
|
|
|
|
Hello !
On vb.net , I have a sub like this :
...
myobj.num=1
Myobj.vl=2
.....
I want to pass Myobj as a parameter when I call the sub. But the problem is that I want to call this same sub , one time when myobj is Type1 , and one time when myobj is Type2 ( Both type1 and Type2 are custom types that both have the fields .num and .vl).
How can I do this ?
Thank you !
|
|
|
|
|
|
The types type1 and type2 are totally different types , but both have the fields that I use on the sub.
|
|
|
|
|
In that case I would suggest you should have different subs. Or better still the types should expose their data content as Properties, which you can then set without needing to check which type it is.
|
|
|
|
|
Both of your "type1" and "type2" classes have fields in common. Ok, so those have to be broken out into something that is common between those two types, either an Interface implementation or a base class that they both inherit from.
You will then be able to pass your "type1" and "type2" class instances as either that interface or base class for the method to use. For example, an interface version would look something like:
Public Interface SomeInterface
Property SomeProperty As String
Property AnotherProperty As Int
End Interface
And both of your "types" would have to implement the interface:
Public Class Type1 Implements SomeInterface
...
End Class
Public Class Type2 Implements SomeInterface
...
End Class
When you define your method that has to accept instances of these two classes, you use the interface to define the parameter expected:
Public Sub MyMethod(ByVal parameter As SomeInterface)
End Sub
The method is saying "I need something that implements this interface". It's a contract where the method expects the object passed in as "parameter" to implement a know interface, guaranteeing the properties defined in the interface will be there in the object that is passed in.
When you go to call this method, you're saying this is an instance of Type1, but since it implements this interface, treat this object as this interface type, not as the Type1 class.
Dim myInstance As New Type1
...
MyMethod(myInstance)
|
|
|
|
|
Easy way is to put those details in their own class, and make that new class part of type1 and type2.
Public Class McBoatFace
Property Num As Integer
Property vl As String
End Class
Public Class Type1
Property Boat As McBoatFace
End Class
Public Class Type2
Property Boat As McBoatFace
End Class
Sub Marine(Boat As McBoatFace)
End Sub
A less easy, but cleaner way would be implementing the McBoatface-class as an interface, and to pass the interface to the sub. Another way to make it cleaner is by putting the Boat-property into a new Type0-class, and inherit Type1 and Type2 from it; makes the property appear in both classes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|