|
Here all numbers and backspace[chr(8)] is allowed in this textboxfield if this code is written in its keypress event.
If (e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = Chr(8) Then
Else
e.Handled = True
End If
Dileep Devapal
|
|
|
|
|
Thank you very much for your help, now it is working.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hello...
Im currentyl trying to create a pluginbased application that can get classes from a dll file and build a user interface from it.
Can annyone help me please, im going mad!!!
|
|
|
|
|
OK, OK!
I had done such a thing a few years ago usin VB6, listen:
(I try to explain it as simple as possible)
Create a VB6 ActiveX DLL project, as your plugin.
This plugin must have a public class (this is the class that is to be connected by your main program.)
EVERYTHING you want this plugins to do, place it in the DLL file and just for things and methods that ALL your plugins are going to do, you must expose the same interface in this class (I mean that this PUBLIC class, must be the same -have the same public methods- in all plugins) so the main program knows what to call!
Now in your main program, call each plugin by this sintax:
Set PlugIns(i)=CreateObject("PluginName.PublicClassName")
Now in your program, you can do methods of each plugin you wish easily:
Call PlugIns(i).SomeMethod()
If you have any problems or questions about what I wrote, ask and I'll explain it to you.
|
|
|
|
|
thanks for the help. but i want to get the intire class in to my application like this
in a normal application i can do like this:
i give you an exsample class:
Public Class someclass : Inherits UserControl
Friend WithEvents mybutton As Button
Public Sub New()
MyBase.new()
mybutton = New Button
mybutton.Top = 0
mybutton.Left = 0
mybutton.Height = 200
mybutton.Width = 200
Me.Controls.Add(mybutton)
End Sub
Dim mybutton As button
Private Sub mybutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mybutton.Click
MessageBox.Show("this is a messagebox")
End Sub
and in a form i could do like this:
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'watch the next line:
Dim myPlugin As New someclass
Me.Controls.Add(myPlugin)
myPlugin.Top = 0
myPlugin.Left = 0
myPlugin.Height = 200
myPlugin.Width = 200
End Sub
what i want to do is have the class named someclass ina seperate dll file
annybody know what i mean?
|
|
|
|
|
I have created a simple VS.NET ASPX form to collect user information. The form has several textbox inputs which the user fills in. Finally after validation clicking on a save button records the information. If I tab through the inputs when entering the info all is well. But if I press the enter key any time instead of the tab key (a common user error I would think) things screw up. Pressing the Enter key seems to re-activate Page_Load which clears the form ready for fresh user input to the whole form. How do I prevent this? Ideally it would seem best to have the Enter key performing exactly the same action as the Tab key.
Bob M
|
|
|
|
|
This question really belongs in the ASP.NET forum. But, I don't think you can do this. You definately CAN'T do it in C# or VB.NET with ASP.NET. If possible, it MUST be done using client-side JavaScript.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi
I just want to know the difference between a Class,Installer Class and Component class. And also
Difference between User Control and Custom Control
|
|
|
|
|
See Wikipedia[^] for the definition of a class. This is because it is the building block that will allow the rest of this answer to make more sense.
A Component class is a heavyweight class. It is designed to allow plugging together of the building blocks of applications more quickly. See MSDN: Component Classes[^]
An Installer Class is just a class, it is also a component, like any other class or component, that has simply inherited the ability to interact with the windows installer, so that if you create an deployment project and include an assembly with an installer class in it you can create instances of specific subtypes of the intaller class to perform customised installation actions. See MSDN: Installer class[^]
The main differences that I see between a custom control and a user control is in the trade off between power and ease-of-creation. User controls are easier to create, but have a higher overhead in order to keep them easy. Custome controls have a lower overhead but you have to write more code to get them to do what you want, but you have greater flexibility.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
hi every one i want to add file version information in the block header part of a .dll file for versioning. pls help i need it very badly
bye
|
|
|
|
|
What kind of DLL? What language and tools are you using? Is this a VS.NET Class Library? If so, it's already there. If you're asking about VB6 I'm pretty sure you just have to setup the resource.
|
|
|
|
|
Okay this is my code
txtTotal.Text = Val(txtSubtotal.Text) + Val(txtAddition.Text) + Val(txtRollaway.Text)
how do I set this to string to make the dollar sign appear
txtTotal.Text = Val(txtSubtotal.Text) + Val(txtAddition.Text) + Val(txtRollaway.Text).ToString("$#,###.00")
does not work it gives the value of 0
|
|
|
|
|
A general programming advise:
"DO NOT STICK TO ONE WAY TO WRITE YOUR CODE, IF ONE DID NOT WORK, BE SURE TO THINK FOR OTHER WAYS"
It may be because you are trying to add a String to an Integer:
Val(txtAddition.Text) Integer
+
Val(txtRollaway.Text).ToString("$#,###.00")<br /> String!!!!
but if you had not recognized it, you might have tried these other lines of code:
<br />
txtTotal.Text = "$" & ( Val(txtSubtotal.Text) + Val(txtAddition.Text) + Val(txtRollaway.Text) )<br />
<br />
'OR:<br />
<br />
txtTotal.Text = Val( Val(txtSubtotal.Text) + Val(txtAddition.Text) + Val(txtRollaway.Text) ).ToString("$#,###.00")<br />
You see, there are always lots of ways to get to a goal.
|
|
|
|
|
Thanks I figured out what I was doing wrong thanks for the input
|
|
|
|
|
help , i need to make a tic tac toe game using control arrays
please help
|
|
|
|
|
Check the information from kidwaresoftware lesson[^]. I forget that tic-tac-toe in which chapter. Try to browse it by yourself.
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Hi,
I am strugling with the propertygrid and a listbox. I am using the
universaldropdowneditor from the codeproject (code below). However I am
populating the listbox via a datasource. The problem I am having is that when
I have a value in the propertygird and edit that, I want the listbox to have
the selectvalue equal to the value that is being edited. Just to make it
clearer:
PropgridVal = Germany
Datasource=
Belgium
France
Italie
Germany
Currently when I edit a value it defaults directly to Belgium, instead of
Germany
I do not understand, when I use listbox.selectedvalue="Germany" the
selectedvalue remains Nothing
please help
David J
Thankks
David J
#Region " UniversalDropdownEditor class "
Public Class UniversalDropdownEditor
Inherits UITypeEditor
Private edSvc As IWindowsFormsEditorService
Private valMemb As ValueMemberAttribute
Public Overloads Overrides Function GetEditStyle(ByVal context As _
ITypeDescriptorContext) As UITypeEditorEditStyle
If Not context Is Nothing AndAlso Not context.Instance Is Nothing Then
Return UITypeEditorEditStyle.DropDown
End If
Return UITypeEditorEditStyle.None
End Function
<refreshproperties(refreshproperties.all)> _
Public Overloads Overrides Function EditValue( _
ByVal context As ITypeDescriptorContext, _
ByVal provider As System.IServiceProvider, _
ByVal value As [Object]) As [Object]
If context Is Nothing OrElse provider Is Nothing _
OrElse context.Instance Is Nothing Then
Return MyBase.EditValue(provider, value)
End If
' Dim att As SourceCollectionAttribute = _
' context.PropertyDescriptor.Attributes( _
' GetType(SourceCollectionAttribute))
'If att Is Nothing Then
' nothing we can do here
'Return MyBase.EditValue(provider, value)
'End If
Me.edSvc = provider.GetService(GetType(IWindowsFormsEditorService))
'If Me.edSvc Is Nothing Then
' nothing we can do here either
'Return MyBase.EditValue(provider, value)
'End If
'prepare the listbox
Dim lst As New ListBox()
Me.PrepareListBox(lst, context)
If Me.valMemb Is Nothing Then
lst.SelectedItem = value
Else
Me.valMemb.SelectByValue(lst, value)
End If
Me.switchloaded = False
Me.edSvc.DropDownControl(lst)
Me.switchloaded = True
' we're back
If lst.SelectedItem Is Nothing Then
value = Nothing
Else
value = lst.Text
'Else
' value = Me.valMemb.GetValue(lst)
End If
Return value
End Function
Private Sub PrepareListBox(ByVal lst As ListBox, _
ByVal context As ITypeDescriptorContext)
Dim SysSetTypeAttr As PropertySysSetTypeAttribute =
context.PropertyDescriptor.Attributes(GetType(PropertySysSetTypeAttribute))
Dim syssetType As Short = SysSetTypeAttr.PropertySysSetTypeAttribute
lst.IntegralHeight = True ' resize to avoid partial items
Dim coll As DataTable =
funGetPropVal(context.PropertyDescriptor.Name, SysSetType)
If lst.ItemHeight > 0 Then
Dim adjHei As Integer = (coll.Rows.Count + 1) * lst.ItemHeight
If Not coll Is Nothing AndAlso _
lst.Height / lst.ItemHeight < coll.Rows.Count Then
' try to keep the listbox small but sufficient
If adjHei > 200 Then adjHei = 200
End If
lst.Height = adjHei
Else ' safeguard, although it shouldn't happen
lst.Height = lst.ItemHeight
End If
lst.Sorted = True ' present in alphabetical order
FillListBoxFromCollection(lst, coll)
Me.AssignValueMember(lst, context.PropertyDescriptor)
Me.AssignDisplayMember(lst, context.PropertyDescriptor)
' attach event handler
AddHandler lst.SelectedIndexChanged, AddressOf Me.handleSelection
AddHandler lst.DoubleClick, AddressOf Me.handledoubleclick
End Sub
Public Shared Sub FillListBoxFromCollection(ByVal lb As ListBox, ByVal
coll As DataTable)
Dim DataRowX As DataRow
' prevent flickers and slow downs by entering the mass update mode
lb.BeginUpdate()
lb.Items.Clear()
lb.MultiColumn = False
Dim intCount As Integer
lb.DataSource = coll
lb.Invalidate()
End Sub
Private Sub AssignValueMember(ByVal lc As ListControl, ByVal pd As
PropertyDescriptor)
Dim Attr As ValueMemberAttribute = New ValueMemberAttribute("Name")
Me.valMemb = Attr 'pd.Attributes(GetType(ValueMemberAttribute))
lc.ValueMember = Me.valMemb.ValuePropertyName
End Sub
Private Sub AssignDisplayMember(ByVal lc As ListControl, ByVal pd As
PropertyDescriptor)
Dim att As DisplayMemberAttribute = New DisplayMemberAttribute("Name")
If att Is Nothing Then Return
lc.DisplayMember = att.DisplayPropertyName
End Sub
Private Sub handleSelection(ByVal sender As Object, ByVal e As EventArgs)
If Me.edSvc Is Nothing Then Return
If Me.switchloaded = False Then Return
Me.edSvc.CloseDropDown()
End Sub
Private Sub handledoubleclick(ByVal sender As Object, ByVal e As
EventArgs)
If Me.edSvc Is Nothing Then Return
Me.edSvc.CloseDropDown()
End Sub
End Class
#End Region
#Region " Attributes "
#Region " Auxiliary attribute that fetches the specified source collection "
<description("service attribute="" to="" point="" the="" source="" collection."),="" _=""
="" attributeusage(attributetargets.all)=""> _
Public Class SourceCollectionAttribute
Inherits Attribute
Private srcCollName As String
Public ReadOnly Property CollectionName() As String
Get
Return Me.srcCollName
End Get
End Property
Public ReadOnly Property Collection(ByVal instance As Object) As
ICollection
Get
Dim pdc As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(instance)
Dim pd As PropertyDescriptor
For Each pd In pdc
If pd.Name = Me.srcCollName Then
Return pd.GetValue(instance)
End If
Next
Return Nothing
End Get
End Property
Public Sub New(ByVal sourceCollectionPropertyName As String)
Me.srcCollName = sourceCollectionPropertyName
End Sub
End Class
#End Region
#Region " 'Value member' attribute "
<attributeusage(attributetargets.all)> _
Public Class ValueMemberAttribute
Inherits Attribute
Private valMemb As String
<description("the name="" of="" the="" property="" used="" as="" value="" member="" by=""
dynamic="" combo="" type="" editor.")=""> _
Public ReadOnly Property ValuePropertyName() As String
Get
Return Me.valMemb
End Get
End Property
Public Sub SelectByValue(ByVal lb As ListBox, ByVal val As Object)
lb.SelectedItem = Nothing
Dim item As Object
If Not val Is Nothing Then
For Each item In lb.Items
If Me.GetValue(item) = val Then
lb.SelectedItem = item
Exit Sub
End If
Next
End If
End Sub
Public Function GetValue(ByVal obj As Object) As Object
If Me.valMemb = String.Empty Then Return obj
' Dim pi As System.Reflection.PropertyInfo =
obj.GetType().GetProperty("Row")
Dim pi As String = obj.text
If pi Is Nothing Then Return obj
Return pi
End Function
Public Sub New(ByVal valueMemberPropertyName As String)
Me.valMemb = valueMemberPropertyName
End Sub
End Class
#End Region
#Region " 'Display member' attribute "
<attributeusage(attributetargets.all)> _
Public Class DisplayMemberAttribute
Inherits Attribute
Private dispMemb As String
<description("the property="" displayed="" in="" the="" list="" control="" used="" by=""
dynamic="" combo="" editor.")=""> _
Public ReadOnly Property DisplayPropertyName() As String
Get
Return Me.dispMemb
End Get
End Property
Public Sub New(ByVal displayMemberPropertyName As String)
Me.dispMemb = displayMemberPropertyName
End Sub
End Class
|
|
|
|
|
Dim lIndex As Long
lIndex = ListBox1.Items.IndexOf("Germany")
ListBox1.SelectedIndex = lIndex
Many Thanks
Harry
|
|
|
|
|
Ok, I've had an Encrypt / Decrypt routine for a year now, but now I'm wondering if I am missing something in it.
It seems that anyone with different Languages installed on their PC, the Decrypt cannot decrypt data on a PC with standard English. So, how can I enable my encryption routine to handle Locales?? I know that I need to convert the String into Locale specific data, but I am not sure where in this code.
Any help is appreciated.
Public Class ICrypto
'<<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>>
#Region "Methods"
'Function to Return a Key
<DebuggerStepThrough()> _
Private Shared Function GetKey(ByVal Data As String, ByVal KeySize As Integer) As Byte()
Dim nSize As Integer = CInt((KeySize / 8) - 1)
Dim vKey(nSize) As Byte
If (Data.Length >= 1) Then
Dim lastBound As Integer = Data.Length
If (lastBound > nSize) Then lastBound = nSize
For i As Integer = 0 To lastBound - 1
vKey(i) = Convert.ToByte(Data.Chars(i))
Next
End If
Return vKey
End Function
'Function to Get the Initialization Vector
<DebuggerStepThrough()> _
Private Shared Function GetIV(ByVal Data As String, ByVal BlockSize As Integer) As Byte()
Dim nSize As Integer = CInt((BlockSize / 8) - 1)
Dim vVector(nSize) As Byte
If (Data.Length >= 1) Then
Dim lastBound As Integer = Data.Length
If (lastBound > nSize) Then lastBound = nSize
For i As Integer = 0 To lastBound - 1
vVector(i) = Convert.ToByte(Data.Chars(i))
Next
End If
Return vVector
End Function
'Function to Encrypt Data
<DebuggerStepThrough()> _
Public Shared Function Encrypt(ByVal Data As String, ByVal Password As String, Optional ByVal ConvertToBase64 As Boolean = True) As String
Dim provCrypto As Cryptography.SymmetricAlgorithm
Dim mEncryptor As ICryptoTransform
Dim stCrypto As Cryptography.CryptoStream
Dim stMemory As IO.MemoryStream, stWriter As IO.StreamWriter
Dim vData() As Byte
Dim sData As String
'Exit if there is no Data
If (IsNothing(Data)) Then Return String.Empty
If (Data.Equals(String.Empty)) Then Return String.Empty
Try
'Initialize the Crypto Provider (3DES)
provCrypto = Cryptography.TripleDES.Create()
provCrypto.KeySize = 128
provCrypto.BlockSize = 64
provCrypto.Mode = CipherMode.CBC
provCrypto.Padding = PaddingMode.PKCS7
'Initialize the Memory Stream and Encrypt the Data
vData = ConvertStringToBytes(Data)
stMemory = New IO.MemoryStream
mEncryptor = provCrypto.CreateEncryptor(GetKey(Password, provCrypto.KeySize), GetIV("Initialization Vector", provCrypto.BlockSize))
stCrypto = New CryptoStream(stMemory, mEncryptor, CryptoStreamMode.Write)
'Write the Encrypted Data
stCrypto.Write(vData, 0, vData.Length)
stCrypto.FlushFinalBlock()
If (ConvertToBase64) Then
'Base64 Encoding enables Saving to XML
sData = System.Convert.ToBase64String(stMemory.ToArray())
Else
sData = ConvertBytesToString(stMemory.ToArray()) 'Encode the Byte Array to UTF8
End If
Catch ex As Exception ': MsgBox(ex.ToString)
Finally
Erase vData
If (Not IsNothing(stMemory)) Then stMemory.Close() : stMemory = Nothing
If (Not IsNothing(stCrypto)) Then stCrypto.Clear() : stCrypto.Close() : stCrypto = Nothing
If (Not IsNothing(mEncryptor)) Then mEncryptor.Dispose() : mEncryptor = Nothing
If (Not IsNothing(provCrypto)) Then provCrypto.Clear() : provCrypto = Nothing
End Try
'Return the Data
Return sData
End Function
'Function to Decrypt Data
<DebuggerStepThrough()> _
Public Shared Function Decrypt(ByVal Data As String, ByVal Password As String, Optional ByVal ConvertFromBase64 As Boolean = True) As String
Dim provCrypto As Cryptography.SymmetricAlgorithm
Dim mDecryptor As ICryptoTransform
Dim stCrypto As Cryptography.CryptoStream
Dim stMemory As IO.MemoryStream
Dim vData() As Byte
Dim sData As String
'Exit if there is no Data
If (IsNothing(Data)) Then Return String.Empty
If (Data.Equals(String.Empty)) Then Return String.Empty
Try
'Initialize the Crypto Provider (3DES)
provCrypto = Cryptography.TripleDES.Create()
provCrypto.KeySize = 128
provCrypto.BlockSize = 64
provCrypto.Mode = CipherMode.CBC
provCrypto.Padding = PaddingMode.PKCS7
'Decrypt the Data
If (ConvertFromBase64) Then
ReDim vData(Data.Length)
vData = System.Convert.FromBase64String(Data)
Else
vData = ConvertStringToBytes(Data)
End If
stMemory = New IO.MemoryStream
mDecryptor = provCrypto.CreateDecryptor(GetKey(Password, provCrypto.KeySize), GetIV("Initialization Vector", provCrypto.BlockSize))
stCrypto = New CryptoStream(stMemory, mDecryptor, CryptoStreamMode.Write)
stCrypto.Write(vData, 0, vData.Length)
stCrypto.FlushFinalBlock()
'Read the Encrypted Data
sData = ConvertBytesToString(stMemory.ToArray())
Catch ex As Exception ': MsgBox(ex.ToString)
Finally
Erase vData
If (Not IsNothing(stMemory)) Then stMemory.Close() : stMemory = Nothing
If (Not IsNothing(stCrypto)) Then stCrypto.Clear() : stCrypto = Nothing
If (Not IsNothing(mDecryptor)) Then mDecryptor.Dispose() : mDecryptor = Nothing
If (Not IsNothing(provCrypto)) Then provCrypto.Clear() : provCrypto = Nothing
End Try
'Return the Data
Return sData
End Function
'Function to Convert a String to a Byte Array
<DebuggerStepThrough()> _
Public Shared Function ConvertStringToBytes(ByVal Data As String) As Byte()
Return System.Text.UTF8Encoding.UTF8.GetBytes(Data)
End Function
'Function to Convert Bytes to a String
<DebuggerStepThrough()> _
Public Shared Function ConvertBytesToString(ByVal Bytes() As Byte) As String
Return System.Text.UTF8Encoding.UTF8.GetString(Bytes)
End Function
#End Region
'<<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>>
'<<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>>
#Region "Class Constructors / Destructors"
'Initialize the Class
Private Sub New()
End Sub
#End Region
'<<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>><<o>>
End Class
|
|
|
|
|
System.Globalization.CultureInfo
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationcultureinfoclasstopic.asp
|
|
|
|
|
Ok, well I knew I needed the CultureInfo Class...but I have no idea how to go about using it!
I guess I will try to create an InvariantCulture and set it to the Current Culture of the Thread. I will save the existing Culture first so I can restore it later.
Does anyone have an example of this?
|
|
|
|
|
Look here in section 3.3
http://www.gotdotnet.com/team/vb/VBSampleGuidelines.htm
|
|
|
|
|
and here is another reference
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomcasemappingssortingrules.asp
|
|
|
|
|
Hi, i need to do an application where i need to have a map and in the map when a click i have to show where is clicked(with a circle or other think) and i neede to save that for printing
thanks
|
|
|
|
|
in the form of a question please...
-jim
|
|
|
|