Thats where I seen it before - Environment. Thanks John, I suggested the wrong one. I hate it when that are so many
different ways to call the same funciton. :(
Printable View
Thats where I seen it before - Environment. Thanks John, I suggested the wrong one. I hate it when that are so many
different ways to call the same funciton. :(
Ok I'll try those Environment functions when I'm home.
Double.TryParse works if the argument passed is numeric but it errors when the passed argument is non-numeric, I just want to verify if a certain data is numeric or not, could Double.TryParse do that of is there any other way?
Another query I have is this, can't the picturebox group controls anymore? There is this control (GroupBox) which replaced it already? In vb6.0 I always tend to use picturebox to group my controls since it has the 3d effect...
Use Double.TryParse like this:You can alter the second and third arguments to modify the behaviour. The function returns False if the string is not a number of the specified format. If the string is a number, the function returns True and the numerical value is contained in the fourth argument.VB Code:
Dim stringToParse As String Dim parsedResult As Double If Double.TryParse(stringToParse, Globalization.NumberStyles.Any, Nothing, parsedResult) Then MessageBox.Show("The string is a number. It's value is " & parsedResult.ToString() & ".") Else MessageBox.Show("The string is not a number.") End If
Use a PictureBox only to display an image. Use a Panel if you want to group controls without the GroupBox's frame. The Panel has a BorderStyle property. I know that you are just learning dee-u, but I think you need to read and experiment a little more before posting every little question. It absolutely was not me, but I'd guess that that is why someone else repped you down for this thread.
Thats more like it, instead of giving me negative reps I would appreciate an advice instead of giving me negative rep. :)
I am actually reading some tutorials/articles about migrating from vb6.0 to vb.net but it seems those things that I need are not tackled and searching the MSDN does not provide any help also hence here I am asking here instead. :( I know its good to experiment and discover things on your own but I want to be properly guided on the .Net way without using the Microsoft.VisualBasic namespace, with it it seems I almost do lots of stuff in VB.Net with my knowledge in VB6.0 but I really want to learn VB.Net without MS.VB namespace... There are really lots of things that confuses me in learning this VB.Net and proper guidance from you experts in this language is all I'm longing. :)
Whats more problematic for me is those examples I run into uses MS.VB namespace! :(
That's because using Microsoft.VisualBasic IS using proper VB.NET. You have fallen into the same trap that I did and have started thinking of using VB Runtime functions as somehow wrong. It is not. If you want to avoid those Runtime functions to learn the System-based alternatives then by all means do so, but be aware that they are just that: alternatives. Many people will write library functions for themselves that wrap up multiple lines of VB.NET code into a one-line function call. That is all the VB Runtime functions do. People say that they are bad because they "are VB6 code", but they are not. You cannot write VB6 code in VB.NET. The help documentation is littered with examples using VB Runtime functions because Microsoft put them there to be used.Quote:
Originally Posted by dee-u
Using Microsoft.VisualBasic I could use IsNumeric, will it be just fine then? Will it not be "VB6.0" code? And if I gain ample knowledge in VB.Net using MS.VB will I now be frowned upon if ever I'll apply for jobs requiring VB.Net skill?
Just like here, that depends on the individual. I give you a 100%, iron-clad guarantee that using IsNumeric is not writing VB6 code. There are people around this forum who will still frown at you for using it though, just like there will be people in the work-force, including prospective employers, who will frown at you. I'd say your time now would be best spent learning the big stuff, like how do I access data using VB.NET, etc. There's no good going to an employer with an alternative to IsNumeric if you don't know what a DataAdapter is. The small stuff will come to you over time, with research and experience, just as it does for everyone. If you see some code on this forum or elsewhere that you don't recognise or understand, look it up in the help. That's what I do and it is one of the best ways to learn.
When I was learning VB6.0 that was my approach before, I didn't care if my code is not optimized or not the best way to do it as long as I could do the same thing with its equivalent optimized code, since I am still learning VB.Net I wish I could already start at the "proper" way...
Will it really be fine investing time using MS.VB at this point in time? In VB6.0 there were things you could do to optimize your code, in VB.Net what should I know if my code is the "best/optimized" way to do it?
And isnt it that VB.Net is still in the process of evolving? What would the future hold for those programmers who still uses MS.VB?
I've been using VB.NET and C# for 18 months without ever having coded in VB6, and I'm still learning new ways to optimise my code, as I'm sure everyone else on this forum is. Just because you don't use Runtime functions doesn't mean that your code is optimised. Just like in everything, you need to decide how to spend your time most productively. If you want to proceed without Runtime functions then by all means do so, but be aware that any time you spend looking for alternatives is time not spent doing something else. It's up to you to decide what is the best use of your time.
As to the future of VB.NET, I doubt anyone around here really knows what will happen to Runtime function support in the future, although many will have an opinion. Like I said either here or in another of your threads, System.Web.Mail is already deprecated in .NET 2.0, so just because you stick to System namespaces is no guarantee of future support, although there are obviously ceratin things, like String.Length, that are unlikely to ever dissappear.
I have found this alternative, what do you think is the more efficient to use?Quote:
Originally Posted by jmcilhinney
VB Code:
Private Sub txtHoursDay_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtHoursWeek.KeyPress 'Only accept numbers If Not e.KeyChar.IsDigit(e.KeyChar.toString) Then e.Handled = True End If End Sub
That code will reject any key presses in the TextBox that are not in the range 0 - 9. I think that prevention is better than cure, i.e. it's better to stop invalid input than allow it and then give the user an error message. With validating TextBox input there are a lot of other circumstances to consider though. Your code will prevent the user using the BackSpace and Delete keys, amongst other things. It also doesn't stop them pasting any old text from the clipboard from the right-click menu. To create a TextBox that properly prevents any non-numeric input while allowing all the things you would normally want, which may include negative numbers and decimals, is more complex than that.
I have actually modified it to allow backspace and other things. I just wish to know what is the better alternative between the two. :)
As I said, in my opinion it is better to prevent invalid input in the first place, if possible, than to allow it and report an error. One thing I always like to do is give the user some audible feedback when I reject a character. I use the Beep function, but for those who don't like Runtime functions you can use the MessageBeep API.