|
I don't base my developments on an "it seems to work" approach:
When given a new compiler for a new language, I'll play with it first for an hour or so, then spend up to two days reading at least one book about it, then get productive right away. And when given an existing code base in that new language, I will not change a thing to it before I feel comfortable with the language, so that IMO is why John asked the question he asked.
|
|
|
|
|
When you explicitly return no value before the function call ends, the default value for the return type is returned. In case of Boolean, it is False.
On a logical side, True is expected to signal a success, when you have not written any code at all, how do you expect it to return True by default.
|
|
|
|
|
It returns False by default.
|
|
|
|
|
Puzzled by this one...
Previously I had a Module that worked perfectly.
It now doesn't.
It is crashing out on this bit
ActiveWorkbook.SendMail _<br />
Recipients:="someone@somewhere.co.uk", _<br />
Subject:="Bank Balances "
The only change is that previously it was held on my hard drive, but now it is on a shared drive (Q:\)
Why would changing the location it is lifted from and saved to stop this line from working?
It is the ActiveWorkbook that I wish to send, not the saved copy on the HDD.
Excel 2007, and it worked until this change.
Is there a work around?
How would I send a file from a HDD as an extension in an email?
------------------------------------
In science, 'fact' can only mean 'confirmed to such a degree that it would be perverse to withhold provisional assent.' I suppose that apples might start to rise tomorrow, but the possibility does not merit equal time in physics classrooms. Stephen J Gould
|
|
|
|
|
Probably because of security for running macros through a network shared directory, you might want to make a local copy on your hard disk, I do not know of any workarounds for this and am pretty confident this is a security issue.
|
|
|
|
|
EliottA wrote: you might want to make a local copy on your hard disk, I do not know of any workarounds for this and am pretty confident this is a security issue.
Done!
And Works.
Did it by creating a temp file on my HDD, sending that, then deleting it.
(Actually I saved to Q: then saved to D:, then closed and reopened from D: and sent, then closed and deleted. Bit of a Kludge, but it works)
Thanks V Much.
------------------------------------
In science, 'fact' can only mean 'confirmed to such a degree that it would be perverse to withhold provisional assent.' I suppose that apples might start to rise tomorrow, but the possibility does not merit equal time in physics classrooms. Stephen J Gould
|
|
|
|
|
I am trying to get the index of an object in an Arraylist. Please see my example. When run I get -1 for the values of Indexof.
I am sure this is a rookie error but any help would be appreciated.
Cheers
Public Class Plateobj
Public Name As String
Public Order As Integer
End Class
Private Sub Go()
Dim Plate As New Plateobj
Dim List As New ArrayList
'Populate arraylist
Plate.Name = "Geoff"
Plate.Order = 3
List.Add(Plate)
Plate = New Plateobj
Plate.Name = "Dan"
Plate.Order = 2
List.Add(Plate)
Plate.Name = "Paul"
Plate.Order = 1
List.Add(Plate)
'Locate the index of each of the following
MessageBox.Show(List.IndexOf(Plate), "Paul")
Plate = New Plateobj
Plate.Name = "Dan"
Plate.Order = 1
MessageBox.Show(List.IndexOf(Plate), "Dan")
Plate = New Plateobj
Plate.Name = "Geoff"
Plate.Order = 3
MessageBox.Show(List.IndexOf(Plate), "Geoff")
End Sub
modified on Friday, November 27, 2009 6:36 AM
|
|
|
|
|
Hi,
You create 5 instances of Plateobj and add 3 of them to the list.
when you reach the first MessageBox.Show statetement, the list contains: Geoff, Dan, Paul.
Nothing changes afterwards, as you don't add the later Plateobj objects.
So the output should be: 2, -1, -1
BTW: I suggest you improve your naming conventions; normally variables use lower-case (plate), and class names don't include "class" or "obj" or such.
FWIW: the list order is independent of the Order member inside Plateobj (until you come up with some code to sort the list based on the Order member of course).
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
You are generating new plate objects for comparison, however IndexOf does an object comparison. The newly created objects will never match anything in your list.
What Indexof is doing is iterating through the list calling Equals to compare each object in turn. The only way your comparison can work is to override the Equals method on your PlateObj . E.g.
Public Overrides Function Equals(ByVal obj As Object) As Boolean
Dim plate As Plateobj = TryCast(obj, Plateobj)
If plate Is Nothing Then Return False
If plate.Name <> Me.Name Then Return False
If plate.Order <> Me.Order Then Return False
Return True
End Function
If only the names need to match then only compare the names.
|
|
|
|
|
Mr Kuryakin
Thanks for the answer this makes sense I did try before posting a compareto function in the plateobj class, which I have successfully used for sorting.
Ok so how to use the code you posted.
1) I assume I add this to the plateobj class ?
2) I get an error that suggests instead of using Overides I should use Overloads
3) Dim plate As Plateobj = TryCast(obj, Plateobj)gives two errors
- TryCast not declared
- 'Plateobj' is a type and cannot be used as an expression.
Could I ask you to insert your code into my example and post back.
Many Thanks
Geoff
|
|
|
|
|
Hello every body
I want to know the ascii code of Backspace and Delet in vb.Net.how I can find those? please tell me the functions.
I want user writes in a textbox only numbers, this is my code
< If IsNumeric(e.KeyChar) = False Then
e.KeyChar = ""
End If >
but in this way user can not use delet and backspace. I want to active these 2 buttons by ascii codes?
please help me. thank you
|
|
|
|
|
You can use following code to check if backspace was pressed:
e.KeyChar == (char)Keys.Back
I just checked in KeyPress event of the textbox. It does not seem to handle delete button press. Hence I think it should work fine.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
thank you, but unfortunately following code does not work:
e.KeyChar == (char)Keys.Back
|
|
|
|
|
Well, that is not the complete code. That is merely the condition you should be having in your if statement. Moreover, that is C#, I don't know how you would check for quality in VB.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Why don't you use Keys enumeration e.g. Keys.Back and Keys.Delete .
|
|
|
|
|
Hi,
some basic info for you:
1. In .NET all characters and strings are Unicode, not ASCII.
2. Hitting a key causes several events, starting with a KeyDown; have a look at KeyEventArgs
3. Keys are identified primarily by their KeyCode, not their KeyChar
4. there is a Keys enumeration to help you identify keys, including all the special keys.
5. only some keys (the ones typically generating text) also fire the KeyPress event
6. you can influence some of the key handling by using ProcessCommandKey, IsInputKey, and maybe some more; however you would seldom need these.
So start using KeyDown event and KeyCode value.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Hi All,
I have a SQL database column "ID", in which I added one by one entries as 2,5,6,1,8... randomely.
I want to arrange these entries in Ascending order so that in datagridview it get displayed in order 1,2,3,4... like this.
Can someone help me on this?
Thanks.
|
|
|
|
|
Use order by in the query/stored procedure you are using to retrieve the data.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
This is not the appropriate forum for your question. Choosing the correct forum helps you get more answers (and better answers).
|
|
|
|
|
If you have a SQL Question Post here
General Database
http://www.codeproject.com/Forums/1725/General-Database.aspx[^]
in the Query that you use to display the Grid with , add the Following line of SQl
Order by ID ASC
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
So I have finally figured out how to dynamically add data to comboboxes created on the fly however I still cant create an on change event for the combobox.
Heres what I am looking at doing.
Set optioncombobox = Me.controls.Add("Forms.ComboBox.1", "Cheese" & comboNumber)
With optioncombobox
.Text = "Please Select an option..."
.left = 114
.width = 276
.top = 102
.Height = 18
End With
While Not (IsEmpty(Range("'Info'!a" & Counter)))
X = Range("'Info'!a" & Counter).Value
If InStr(1, X, "|") > 0 Then
Else
With controls("Cheese" & comboNumber)
.AddItem (Range("'Info'!b" & Counter).Value)
End With
End If
Counter = Counter + 1
Wend
Then I am trying to create something like this
Private Sub Controls("Cheese1")_Change()
Do Stuff
End Sub
But I am getting an error saying "Expected: Identifier"
Anyone have any thoughts on how I can resolve this??
However when I create a commandbutton click event it can do all of this with no issue.
But I want to do this in an On Change event.
Even if there is some way to run an event if any combobox on the whole form changes that would be fine.
|
|
|
|
|
In VB6, handling events for dynamically added controls in quite difficult. There is a keyword WithEvents that may help you, but I am not sure how you can use it with dynamically added controls.
Your syntax for event method declaration is totally wrong Work on the WithEvents keyword.
|
|
|
|
|
Why are you still using VB6 in 2009 ?
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi,
I am using SQL database with VB. The database "company" has 1 column "EmpID" which I filled with 0,1,2,... so on, and "EmpID" column is in string format.
Now I want to get the MAX of this "EmpID", for this I wrote a code like this in VB :
SELECT MAX(EmpID) From company.
I found that out of 0 to 150 EmpID in database, it is selecting MAX value as 9 and sometime as 99.
I think there is something wrong with this. Also, If I test it for small data, say from 1 to 15, it is selecting correct MAX value.
Can someone help me how to do this? My basic idea is to get the last "EmpID" which I will add and use it as next "EmpID".
Thanks
R.S.
|
|
|
|
|
I think that is because your EmpId id not an integer in your database. It something be varchar or something similar. You should change it to int if it can have only integer values. In order to make the query work in current condition, use following:
SELECT MAX(cast(EmpID as int)) From company
Note that this is not a good practice.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|