|
I have read some of the articles on this site and others reguarding this issue and all of them involve custom controls or writing a class to accomplish this simple task. Someone has got to know a simple easy way to accomplish this with a few lines of code. I mean VB6 had this property for the textboxes but .NET doesnt and you have to make a custom control or write a class??? This doesnt make any sense. If anyone knows of a simple way to make a textbox accept ONLY numeric and ONLY alpha, please let me know. Thank you in advance.
|
|
|
|
|
pass the 'e' argument of the keypress event of the textbox into either routine:
Public Sub KeyPress_Numeric_Only(ByVal e As System.Windows.Forms.KeyPressEventArgs)
Select Case Asc(e.KeyChar)
Case Keys.Back, Keys.D0 To Keys.D9
'continue
Case Else
e.Handled = True
End Select
End Sub
Public Sub KeyPress_Alpha_Only(ByVal e As System.Windows.Forms.KeyPressEventArgs)
Select Case Asc(UCase(e.KeyChar))
Case Keys.Back, Keys.A To Keys.Z
'continue
Case Else
e.Handled = True
End Select
End Sub
|
|
|
|
|
is this going to work for the seperate keypad as well??? (keypad on the right of keyboard...
|
|
|
|
|
sorry:
Public Sub KeyPress_Numeric_Only(ByVal e As System.Windows.Forms.KeyPressEventArgs)
Select Case Asc(e.KeyChar)
Case Keys.Back, Keys.D0 To Keys.D9,keys.numpad0 to keys.numpad9
'continue
Case Else
e.Handled = True
End Select
End Sub
|
|
|
|
|
I get an error, "Failed to open rowset" when I try and produce an Crystal Report. I am using VB.Net 2003 with CR 8.5. The report database is a text file. I have tried vertifying the database etc but with no luck. Maybe there is something wrong with my Vb code which I have included. Am I doing something stupid with the code. Any help please?
It is a simple setup. Form with a button and Crystal Report Viewer.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strReportPath As String = "C:\Program Files\reports\report1.rpt" 'report1
Try
'Load Crystal Report's rpt file
Dim cr As New CrystalDecisions.CrystalReports.Engine.ReportDocument
cr.Load(strReportPath)
CrystalReportViewer1.ReportSource = strReportPath
'Set the CrystalReportViewer's apperance and set the ReportSource
CrystalReportViewer1.ShowRefreshButton = False
CrystalReportViewer1.ShowCloseButton = False
CrystalReportViewer1.ShowGroupTreeButton = False
CrystalReportViewer1.Zoom(1)
CrystalReportViewer1.ReportSource = cr
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
|
|
|
|
|
I didn't realise that VB 6 was obsolete. What is a good program for a starter? I don't have any specific uses i want to use it for, just to learn more about computers, in general.... J.Paul Ghetty.
|
|
|
|
|
VB.Net is good for starters.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
You can find the free Express Editions of VB.NET, C#, and others here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Oh, he was asking about programs to use, not about languages.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
And your reply to the OP was what? How about a direct reference to a language and development environment!
The OP said that VB6 was obsolete - it is. To me, this means he's looking for the same thing, only more modern. So, I directed him to the free versions of development environments we use today.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
VB.NET is the step child of VB6. C# and VB.NET are both .NET languages, if you like BASIC like syntax, VB.NET is the way to go.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I added a "Discard Unsaved Changes" button to my form.
I want to loop through all the Bindingsources on my form and do a .CancelEdit() on each one in order to discard the changes. (If this is even the way to do it)
Dim BS as new System.Windows.Forms.BindingSource<br />
<br />
For Each BS in ???????<br />
BS.CancelEdit()<br />
Next
I need to get some sort of a BindingSourceCollection object at the ???'s, how do I do this?
(Visual Studio 2005)
you can't forget something you never knew...
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
There is no seperate BindSources collection on a form. It's a control, just like any other. You have to go through the form's Controls collection and find them.
For Each c As Control in Me.Controls
If TypeOf c Is BindingSource Then
Dim bs As BindingSource = DirectCast(c, BindingSource)
' do whatever you want to the bs object...
End If
Next
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi, Thanks for the help.
Dave Kreskowiak wrote: If TypeOf c Is BindingSource Then
The above line generates a syntax error stating:
Expression Type: 'System.windows.forms.control' can never be of the type 'System.windows.forms.bindingsource'
Any ideas?
you can't forget something you never knew...
"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann
|
|
|
|
|
Whoops! My bad. I made a stupid assuption about BindingSource. It won't work because BindingSource doesn't inherit from Control.
No big deal. When you create your BindingSource objects, add them to your own collection. Then you have them all in one place.
Dim bindList As New List(Of BindingSource)
.
.
.
bindList.Add(BindingSource1)
bindList.Add(BindingSource2)
.
.
.
For Each b As BindingSource In bindList
' do what you need to do to your BindingSources
b.whatever...
Next
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I added the line I need from an old .NET 1.1 project Inherits System.ComponentModel.Component so that I can drag the SPs onto the component and have everything typed correctly as well as spelled correctly but it isnt working. Is there a new way to do this in 2.0??
Cleako
|
|
|
|
|
Define "isn't working". The Component class is still there are works the same way it did in previous versions of the Framework.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
When I go to add a new item, both in the App_Code and in the project itself, it isnt showing.
Cleako
|
|
|
|
|
If you add the Inherits Component line to the class header, this adds the default implementation of the IComponent interface to your class. It doesn't automatically make it a control with a design surface.
What are you trying to create with this? A new control? You might want to inherit from Control instead, which automatically includes inheriting from Component. It also provides the default implementation for IDropTarget, among others.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want to drag and drop stored procedures onto the designer so that I dont have to worry about user error with types and parameter names.
Cleako
|
|
|
|
|
You mean, you want to drag and drop an SP on YOUR COMPONENT and have the SQL code generated for you?
IMHO, the worst way to do it. The best, and easily supported, SQL code is written by hand, not by the designer.
I've never done it with drag and drop, other than to play with it, and I remember quickly abandoning it because it put objects and code crap all over the place in the form code. Precisely where it didn't belong.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Not the SQL code itself I just liked that it laid out the parameters for me that were already present in the pre-written stored procedure. Also, the only thing I used the component class for was for that purpose so it only contained DB calls and I wrote all of the code myself other than the Parameters.Add stuff.
Cleako
|
|
|
|
|
Well, you can try inheriting from Control and see what happens. I, personally, don't like the idea because of the extra crap your class has to deal with that it will never use, just so you can have some code written for you.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Are you saying you dont use wizards?
Im not a big wizard user myself but I do use a couple of the code generating options such as the drag and drop stored procedure. Ive noticed that many places on the net only show you how to do things through wizards.
What would you recommend for the data access class anyway? Ive seen some examples where the data access class just contains the Open and Close connection methods as well as the execute stored procedure methods and all the of the information is passed in from somewhere else. My experience has been to put all of the code the data access class uses cmd.Parameter("Name").Value = "Name" explicitly instead of a generic loop that adds the parameters. What do you think?
Cleako
|
|
|
|
|
cleako wrote: Are you saying you dont use wizards?
Never. I write all my database code by hand. I get far greater control and it's much easier to support.
cleako wrote: Ive noticed that many places on the net only show you how to do things through wizards.
You won't find that here.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|