|
If you want the first item in the combo box to be selected, can't you just use:
ComboBox1.SelectedIndex = 0
?
|
|
|
|
|
no even that gives the second item
|
|
|
|
|
Are you sure that:
A) this code block is being executed
B) there isn't any other code which sets the selected index of the combo box after this code block.
I'm guessing that the index is being set elsewhere because ComboBox1.SelectedIndex = 0 will select the first item.
|
|
|
|
|
Yes i am sure
i wrote
if combobox.selectedindex = 19 then
combobox.selectedindex = 0
end if
and this gives me the second item
i had tried that before thats why i asked it here.
i would say try it.
|
|
|
|
|
Ah, I have just tested and found that after the selected index of the combo box is set, the mouse wheel movement is actioned. That is, if you scroll downwards, then after setting the combobox to index 0, the scroll down is done (but if you scroll upwards then it is fine).
The only way I can think of around this (which isn't very pretty) is to add and event handler after setting the index of the combo box. Something like:
Private Sub ComboBox1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ComboBox1.MouseWheel
If ComboBox1.selectedindex = 19 then
AddHandler ComboBox1.SelectedIndexChanged, AddressOf SetIndex
End If
End Sub
Private Sub SetIndex(ByVal sender As Object, ByVal e As System.EventArgs)
ComboBox1.SelectedIndex = 0
RemoveHandler ComboBox1.SelectedIndexChanged, AddressOf test
End Sub
Like I said, not a pretty solution so maybe someone else has other ideas?
modified on Wednesday, April 22, 2009 1:47 PM
|
|
|
|
|
your solution doesn't work because of the word "test".
Test is not decleared.
if i change it to setindex in run the project then the first item does not come it stays at the last item.
sorry couldn't response earlier
thanks
|
|
|
|
|
the only ting i can do is ad an emtpty string as last item
and then
If ComboBox1.SelectedIndex = 20 Then
ComboBox1.SelectedIndex = 0
20 is the last item as a empty string
that works but it's like you said even not so nice.
|
|
|
|
|
I figured out a solution:
dim i as integer
Private Sub ComboBox1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ComboBox1.MouseWheel
Try
If ComboBox1.SelectedIndex = ComboBox1.Items.Count - 1 And e.Delta = -120 Then
i = ComboBox1.SelectedIndex
ComboBox1.SelectedIndex = 0
Else
Me.OnMouseWheel(e)
End If
Catch ex As Exception
ComboBox1.SelectedIndex = 0
End Try
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If i = ComboBox1.Items.Count - 1 And ComboBox1.SelectedIndex = 1 Then
ComboBox1.SelectedIndex = 0
i = 0
End If
End Sub
It's funny though, how that mouse wheel event only lets you perform actions in between turns (so to speak).
My advice is free, and you may get what you paid for.
modified on Thursday, April 23, 2009 3:22 AM
|
|
|
|
|
thanks eddy that's it
thank you
|
|
|
|
|
You're welcome.
Now you just need to figure how to adapt this to also work when you scroll up
Cheers,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
again thanks johan.
sorry for mistyping your name
|
|
|
|
|
Hi,
How is this happening then?
Setting the Text property of the combobox implicity changes the SelectedIndex property. Therefore your code must set SelectedIndex to 0.
ComboBox1.Text = ComboBox1.Items(0).ToString()
But what happens next? The default mouse wheel handling then increments the SelectedIndex from 0 to 1 to give the observed effect of always getting the second item selected.
The solution must be to disable the default handling for the one special case of wrapping the index from bottom to top and you’ll have to do this via an override of the OnMouseWheel method.
In c# I'd do this
protected override void OnMouseWheel(MouseEventArgs e) {
if (specialcase) {
SelectedIndex = 0;
} else {
base.OnMouseWheel(e);
}
}
Let me know if this works, as it's a bit of a guess on my part.
Alan.
modified on Wednesday, April 22, 2009 9:33 PM
|
|
|
|
|
i can't make it working because
specialcase is not declare
|
|
|
|
|
johnny1963 wrote: i can't make it working because
specialcase is not declare
Oh come on, try using your brain this morning! Specialcase is just a placeholder for the boolean condition that you already have,
VB x = 95 AndAlso e.delta = -120
c# x == 95 && e.delta == -120
Also you will need to subclass the combobox class to override the method.
Alan.
|
|
|
|
|
Hi Alan i have the right code from Johan Hakkesteegt thanks for your help.
|
|
|
|
|
I have below macro which will retrieve Microsoft excel password.
But it will not retrive word template password
can anyone help out please ?
Public Sub AllInternalPasswords()
' Breaks worksheet and workbook structure passwords. Bob McCormick
' probably originator of base code algorithm modified for coverage
' of workbook structure / windows passwords and for multiple passwords
'
' Norman Harker and JE McGimpsey 27-Dec-2002 (Version 1.1)
' Modified 2003-Apr-04 by JEM: All msgs to constants, and
' eliminate one Exit Sub (Version 1.1.1)
' Reveals hashed passwords NOT original passwords
Const DBLSPACE As String = vbNewLine & vbNewLine
Const AUTHORS As String = DBLSPACE & vbNewLine & _
"Adapted from Bob McCormick base code by" & _
"Norman Harker and JE McGimpsey"
Const HEADER As String = "AllInternalPasswords User Message"
Const VERSION As String = DBLSPACE & "Version 1.1.1 2003-Apr-04"
Const REPBACK As String = DBLSPACE & "Please report failure " & _
"to the microsoft.public.excel.programming newsgroup."
Const ALLCLEAR As String = DBLSPACE & "The workbook should " & _
"now be free of all password protection, so make sure you:" & _
DBLSPACE & "SAVE IT NOW!" & DBLSPACE & "and also" & _
DBLSPACE & "BACKUP!, BACKUP!!, BACKUP!!!" & _
DBLSPACE & "Also, remember that the password was " & _
"put there for a reason. Don't stuff up crucial formulas " & _
"or data." & DBLSPACE & "Access and use of some data " & _
"may be an offense. If in doubt, don't."
Const MSGNOPWORDS1 As String = "There were no passwords on " & _
"sheets, or workbook structure or windows." & AUTHORS & VERSION
Const MSGNOPWORDS2 As String = "There was no protection to " & _
"workbook structure or windows." & DBLSPACE & _
"Proceeding to unprotect sheets." & AUTHORS & VERSION
Const MSGTAKETIME As String = "After pressing OK button this " & _
"will take some time." & DBLSPACE & "Amount of time " & _
"depends on how many different passwords, the " & _
"passwords, and your computer's specification." & DBLSPACE & _
"Just be patient! Make me a coffee!" & AUTHORS & VERSION
Const MSGPWORDFOUND1 As String = "You had a Worksheet " & _
"Structure or Windows Password set." & DBLSPACE & _
"The password found was: " & DBLSPACE & "$$" & DBLSPACE & _
"Note it down for potential future use in other workbooks by " & _
"the same person who set this password." & DBLSPACE & _
"Now to check and clear other passwords." & AUTHORS & VERSION
Const MSGPWORDFOUND2 As String = "You had a Worksheet " & _
"password set." & DBLSPACE & "The password found was: " & _
DBLSPACE & "$$" & DBLSPACE & "Note it down for potential " & _
"future use in other workbooks by same person who " & _
"set this password." & DBLSPACE & "Now to check and clear " & _
"other passwords." & AUTHORS & VERSION
Const MSGONLYONE As String = "Only structure / windows " & _
"protected with the password that was just found." & _
ALLCLEAR & AUTHORS & VERSION & REPBACK
Dim w1 As Worksheet, w2 As Worksheet
Dim i As Integer, j As Integer, k As Integer, l As Integer
Dim m As Integer, n As Integer, i1 As Integer, i2 As Integer
Dim i3 As Integer, i4 As Integer, i5 As Integer, i6 As Integer
Dim PWord1 As String
Dim ShTag As Boolean, WinTag As Boolean
Application.ScreenUpdating = False
With ActiveWorkbook
WinTag = .ProtectStructure Or .ProtectWindows
End With
ShTag = False
For Each w1 In Worksheets
ShTag = ShTag Or w1.ProtectContents
Next w1
If Not ShTag And Not WinTag Then
MsgBox MSGNOPWORDS1, vbInformation, HEADER
Exit Sub
End If
MsgBox MSGTAKETIME, vbInformation, HEADER
If Not WinTag Then
MsgBox MSGNOPWORDS2, vbInformation, HEADER
Else
On Error Resume Next
Do 'dummy do loop
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
With ActiveWorkbook
.Unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If .ProtectStructure = False And _
.ProtectWindows = False Then
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
MsgBox Application.Substitute(MSGPWORDFOUND1, _
"$$", PWord1), vbInformation, HEADER
Exit Do 'Bypass all for...nexts
End If
End With
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
If WinTag And Not ShTag Then
MsgBox MSGONLYONE, vbInformation, HEADER
Exit Sub
End If
On Error Resume Next
For Each w1 In Worksheets
'Attempt clearance with PWord1
w1.Unprotect PWord1
Next w1
On Error GoTo 0
ShTag = False
For Each w1 In Worksheets
'Checks for all clear ShTag triggered to 1 if not.
ShTag = ShTag Or w1.ProtectContents
Next w1
If ShTag Then
For Each w1 In Worksheets
With w1
If .ProtectContents Then
On Error Resume Next
Do 'Dummy do loop
For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
.Unprotect Chr(i) & Chr(j) & Chr(k) & _
Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If Not .ProtectContents Then
PWord1 = Chr(i) & Chr(j) & Chr(k) & Chr(l) & _
Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
MsgBox Application.Substitute(MSGPWORDFOUND2, _
"$$", PWord1), vbInformation, HEADER
'leverage finding Pword by trying on other sheets
For Each w2 In Worksheets
w2.Unprotect PWord1
Next w2
Exit Do 'Bypass all for...nexts
End If
Next: Next: Next: Next: Next: Next
Next: Next: Next: Next: Next: Next
Loop Until True
On Error GoTo 0
End If
End With
Next w1
End If
MsgBox ALLCLEAR & AUTHORS & VERSION & REPBACK, vbInformation, HEADER
End Sub
|
|
|
|
|
There is no way to modify this to work with Word. It's (very) specifically written to work only on Excel workbooks and, according to the comments, doesn't even reveal the plaintext password, but the hashed version of it.
Noone is going to help you write a tool to crack passwords. Period.
|
|
|
|
|
OK, i see several softwares to retrieve word .dot file password. One i used it is this ...
http://www.petri.co.il/word-password-recovery.htm[^]
But none of them worked because, the software is trying to retrieve default project in the dot file. Not the second project which i need to retrieve the password.
Do you have any suggestions to come up on this?
|
|
|
|
|
Chances that anyone is going to help you are slim, since you're trying to open things that the original owner doesn't want you to open.
As comparison, you wouldn't want me to explain how everyone can retrieve the password to your computer, now would you? No amount of locks on the door will keep you 100% safe, but that doesn't mean that we should encourage burglary
There are enough programs available for free that do this stuff. Use them at your own risk.
I are troll
|
|
|
|
|
Agree,
But this my user forgot his password and he own want to get it rectified it.
Without opening the .dot file i cannot solve his problem.But he forgot the password to open the file though.
The problem is, He has upgraded the ms office version and template (Somename.dot) was supporting was not supporting now. When i start saving the file i am getting error.
How i can get rid of this? any ideas ? so that i can atleast save that file.
|
|
|
|
|
Jaison Peter wrote: When i start saving the file i am getting error.
So you can 'open' and 'read' it? Copy and paste to a new file, and save that?
I are troll
|
|
|
|
|
Word file (.doc) and template file (.dot) are different things.
Dot file resides inside doc file. I can enable/disable dot file inside doc file using tools>template and add-in> and UN-ticking the doc file.
But which enabling i cannot save the doc file, if i disable i could.
i can debug the macro template project only if i have the password.
It will prompt for password even for debugging the macro.
|
|
|
|
|
UN-ticking the doc file.<br />
UN-ticking the dot file.
|
|
|
|
|
Jaison Peter wrote: Dot file resides inside doc file.
I'm saving my templates in a separate folder, there's more than just a normal.dot.
Lots of developers wanted to be able to protect their macro's, afraid that someone steals tha codez. Protection has it's downsides. You can try some of the brute-force tools on the net, Google is your friend there.
I are troll
|
|
|
|
|
i have a procedure in SQL Server which takes a sum of a column between two values and the ID of the partner but how should I call that procedure on a button click event and populate that sum in a textbox by giving as an argument of the values from tree comboboxes which are the two values and the partner.
here is the procedure
create procedure pvShuma
(
@PartneriID int,
@XhiroPrej int,
@XhiroDeri int
)
as
select sum(Hyrje) from dbo.tblXhiro
where NrXhiro between @XhiroPrej and @XhiroDeri
and PartneriID = @PartneriID
thanks for any advice!
Qendro
|
|
|
|