|
Are any of the parameter values an empty string??
|
|
|
|
|
Discovered problem, the actual value of my salt field in database wasn't long nuff for some reason had it only set to 50.
Been at this too long i thinks, although i now have my page working
Cheers People
|
|
|
|
|
Glad it sounds like you got it figured out
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
well no1 whose got a girlfriend is goin to be hacking my passwords anytime soon
|
|
|
|
|
I noticed you were using SHA384 , and that should be plenty sufficient for some time
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I'm working on my first vb.Net project I have a field that is not required, but is numeric. If the user leaves the field blank I get the following error, when I try to use it set a value in my object.
InvalidCastException: Cast from string "" to type 'Integer' is not valid.]
Here is the code.
MyShelled.KC = Me.txtKC.Text
Here is the object's property
Public WriteOnly Property KC() As Integer
Set(ByVal NewVal As Integer)
MyKC = NewVal
End Set
End Property
I've tried to create overloaded properties but I get the following compile error.
c:\inetpub\wwwroot\Shelling\clsZebra.vb(228): 'Public Overloads WriteOnly Property KC() As Integer' and 'Public Overloads WriteOnly Property KC() As String' cannot overload each other because they differ only by return types.
I'd like to handle this in my class but I'm not sure how to go about. Any direction would be great.
Thanks
Travis
|
|
|
|
|
If Not IsNothing(Me.txtKC.Text) AndAlso me.txtKC.text.trim <> String.Empty Then
MyShelled.KC = Me.txtKC.Text
End If
|
|
|
|
|
FYI, to handle in your class, you would need to define your property as an object so that it can accept different datatypes like strings and numbers, etc. then filter out anything you don't want to allow like empty strings, etc.
|
|
|
|
|
mymacryan wrote: MyShelled.KC = Me.txtKC.Text
This happens because VB is weakly typed ( aka sucks ). You need to set a default value if the string is empty. One way to do this is to pretend it's strongly typed and use int.TryParse to see if you get an int out of it, and otherwise set a default. This has the advantage of not assuming your presentation layer has only allowed numbers to be entered.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian,
I'm curious...
he has his property set as type 'integer' you can set a default value on that where you send an empty string to the property and the default will be applied instead of throwing an exception?
how do you do that?
|
|
|
|
|
|
When i run my application, backgroundworker starts. Then i stop it by exiting the sub and when i try to start it again, it says backgroundWorker is busy.
How can i reset the Background Worker so it can start again? (.CancelAsync doesent work)
|
|
|
|
|
set this property to true when you first setup the variable for the backgroundworker then the cancel will work
Worker.WorkerSupportsCancellation
|
|
|
|
|
i forgot to mention it was already set to true. It stops fine, it's only when i want to restart that it gives me an exception.
here is part of the code: (cancellation support is already set to true)
Private Sub stopdwlbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stopdwlbut.Click
Me.bgworker1.CancelAsync()
End Sub
Private Sub bgworker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgworker1.DoWork
For Y = 1 To numsites
'does what i want it to do
If Me.bgworker1.CancellationPending Then
e.Cancel = True
CType(bgworker1, BackgroundWorker).ReportProgress(0)
Exit Do
End If
End Sub
Private Sub bgworker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgworker1.ProgressChanged
If e.ProgressPercentage = 0 Then
Downloadbut.Enabled = True
stopdwlbut.Enabled = False
MsgBox("download canceled")
Else
'does something else
End If
End Sub
|
|
|
|
|
then reset it...
worker.dispose
worker = nothing
worker = new backgroundworker
|
|
|
|
|
cool, thx alot for the quick reply, it finally worked
|
|
|
|
|
Once a thread is stopped, it cannot be restarted. You have to destroy it and create a new one.
|
|
|
|
|
Hello
I have 2 combo boxes that are bound to 2 different binding sources. The binding source are bound to the same table adapter.
The customer want to remove an orderID number from one of the combo boxes, the other combo box should still have the orderID number. (remove from one, but leave the other)
I have tried to remove the orderID number for the binding source. But this removes the orderID from both combo boxes.
If i remove the orderID from the combo box itself then I have to remove the binding itself. Which leave no orderIDs in the combo box itself. So that doesn't work either. This is my code for removing it from the bindingsource.
Dim index = Me.bsPendingOrders.Find("OrderID", Me.cboPendingOrders.SelectedValue)<br />
If Not (index = -1) Then<br />
Me.bsPendingOrders.RemoveAt(index)<br />
End If
Many thanks for any suggestions.
|
|
|
|
|
You need to create two identical binding sources, so when you remove from one, the other one is unaffected.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey,
I'm trying to save a file with the SaveAs function under the Word.Document... However, if I have a file of the same name, it simply overwrites without giving me a prompt to do so.. Is there any way around this? I checked the list of parameters, and none of them give like, a boolean for 'SaveOverride' or whatever. Thanks.
---
reegan41
|
|
|
|
|
According to the SaveAs help documentation the default behaviour is to overwrite without prompting. What you can do is test to see if the file your are going to save as already exists, and then do something to select another name. In the code example below, if the file "c:\test.doc" exists the while loop will try for "c:\test_1.doc". If that file exists, it will then try for "c:\test_2.doc" and so on.
<br />
Dim I As Long<br />
Dim SaveAsFileName As String<br />
Dim NewSaveAsFileName As String<br />
<br />
SaveAsFileName = "c:\Test.doc"<br />
NewSaveAsFileName = SaveAsFileName<br />
<br />
While Dir(NewSaveAsFileName, vbNormal) <> ""<br />
<br />
I = I + 1<br />
NewSaveAsFileName = Left(SaveAsFileName, Len(SaveAsFileName) - 4) & "_" & i & _<br />
Right(SaveAsFileName, 4)<br />
<br />
Wend<br />
|
|
|
|
|
Hi There,
My Propblem is quite straight forward, but after searching for an answer, I am now more confused than before.
When using reference types as arguments, should the Argument be declared By Value (Byval) or By Refrence (Byref), to obtain the best performance.
ie:
Private Sub DoStuff (ByVal Connection as SQLConnection)
or
Private Sub DoStuff (ByRef Connection as SQLConnection)
On the one hand it feels like ByRef would be better, since the address of the instance would be used, rather than a copy of the instance. But then I read an article that states VB.net when using ByRef actually creates a copy of the instance, uses it as the argument, then copies it back to the original instance. But Byval only Boxes it once, therefore Byval would be faster.
Can anyone give me some clarity on this?
Thanks in advance
Rob
|
|
|
|
|
Wow - another way that VB totally sucks and shoots you in the foot ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
This is how I understand it:
SQLConnection is a class, hence a reference type. What gets passed along in
case of a reference type is always an address:
the address of the object when ByVal,
the address of the address of the object when ByRef.
(I am purposely avoiding the word "reference")
There is no data copying, and hence there wont be much performance difference,
there is however a functional difference:
A reference type passed ByVal can be operated on, but it can not be replaced
by the callee in such a way that upon return the caller suddenly holds
another object;
caller will always hold its original object, possibly in an evolved state
(since callee could execute its methods, and access its properties).
A reference type passed ByRef can be operated on (as is the case in ByVal), but
it can also be replaced by callee in such a way that the caller also gets
the new object (or Nothing) upon return of the callee.
Hope this helps
|
|
|
|
|
OK, you've got a bad example. Boxing/Unboxing only applies to Value types being treated as objects. Your example doesn't involve boxing at all.
Reference types are anything that is defined by Class, Interface, Delegates, ... These objects are allocated on the heap and a variable holds a reference, or address, to that instance of the object.
Value types, like Integer, Long, Date, Char, Boolean, Structure, Enum, or anything else that decends from System.ValueType, are allocated on the thread's stack, not on the heap.
Boxing occurs when a Value type is treated as an Object, or reference type. When a value is cast to a reference type, most often as an System.Object, a heap allocation is made for a new Object type and the value data is copied into this object. Now you have two copies of the data, one on the stack as a value type and one on the heap as a reference type.
Unboxing is, of course, the reverse of boxing. The data in the "box" is copied back into the thread's stack where it will be treated as a value again.
For example, when you pass a value type to a method that takes an Object parameter, then use the Object as a value in the method, two copy operations occur. One for boxing the value into an Object and another when the value is unboxed back into a value type. These copy operations are expensive! (Ignore the ByVal pass for now...)
...
Dim i As Integer = 5
' Since the parameter for Method is Object, the
' value 5 will be boxed into an Object.
Method(i)
...
Private Sub Method(ByVal x As Object)
' this line causes an UnBox of the value...
Dim y As Integer = x + 5
End Sub
Now, throw collections into this mix and you've the potential for a serious problem. Notice that all the Collection classes, like ArrayList, take an Object as their Item member data type?? In the ArrayList example, look at the Item property documentation and it's return type, Object. Now imagine storing 10,000 Integers in an ArrayList. You just boxed 10,000 Integers into Object types by doing that. And every time you access one of those boxed Integers, say changing one, you unbox the Integer onto the stack, change the value, then rebox the new value back into an Object on the heap! Yeow!
These rules apply equal to VB.NET AND C# (Christian )
OK, ByRef and ByVal is a completely seperate issue... in the next post..
|
|
|
|
|