Volte
*Experts*-
Posts
2372 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Volte
-
Certainly. '-- In the form Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim btn As New Button() With btn .Size = New Size(90, 40) .Location = New Point(15, 15) .Text = "Testing 1 2 3" 'causes the newbtnClick procedure to fire on the click event. AddHandler btn.Click, AddressOf newbtnClick End With Me.Controls.Add(btn) End Sub Private Sub newbtnClick(ByVal sender As Object, ByVal e As EventArgs) MessageBox.Show("You clicked the button!") End Sub
-
Well, you don't need a form. You may be able to remove the form and simply use a class that contains a NotifyIcon defined in code. I'm not sure though; I rarely use formless Windows applications.
-
You need to put a NotifyIcon componenet from the toolbar on your form. I'm sure that you'll find information in your MSDN about it. :)
-
This isn't necessarily a good thing. It's because of its simplicity and ease of use that it is widely considered a "newbie language". Of course, the people that call it that are obviously uninformed, they do have a point that it is a very beginner-like language. It took me less than half-an-hour to learn the concepts of .NET, being an experienced VB6 programmer. It may be a bit advanced for the rookie programmers, but it's still an excellent place to start. If it's business you are concerned about, then you do have a point. The time may not be right to switch now, because of the lack of experienced .NET programmers. If the system that you have now with VB6 works, there's no point switching. But that's no to say that you shouldn't still persue .NET; it'll get more popular very fast.
-
Just remember, the garbage collector doesn't always free 100% of the memory. The GC only collects memory that isn't being used by any objects.
-
It has to be 'VALUES' with an 'S', I believe.
-
Try re-registering ASP.NET with IIS. Go to Start -> Run, and run C:\WINNT\Microsoft.NET\Framework\v1.0.3705\aspnet_regiis.exe /iChange the path to reflect what it is on your computer. When you installed ASP.NET the first time, there may have been a problem, so perhaps reregistering it would fix it. Just a guess, though.
-
OK, first this you have to do is go to the 'Project' menu and click 'Add Reference'. Find 'System.Web.dll' in the list of references, and double click it, then click OK. Then the code will work. Dim m As System.Web.Mail.SmtpMail Dim sFrom, sTo, sSubject, sMessage As String sFrom = "email@mail.com" sTo = "email@mail.com" sSubject = "This is a test" sMessage = "Blah blah blah" m.Send(sFrom, sTo, sSubject, sMessage)
-
None of these concepts are "new" at all (at least not most of them.) They have all been around in C++ for a very long time, VB.NET has just integrated them very deeply into the framework. ADO.NET and ADO are not the same thing, nor do they have the same name. BASIC and Visual Basic are not the same thing, yet they share a similar name, and the same goes with VB and VB.NET. We have lost no functionality with going to WinForms; we have gained an absolutely insane amount. You can do 10x what you used to be able to do with forms now; Forms in VB weren't classes in VB's eyes, so they were hardly expandable at all. In the case of VB.NET's eyes, every object is a class making it very expandable indeed. One point I do agree with is that VB's simplicity is gone. But the usability is still there; you just have to know the language. With VB6, any newbie programmer could sit down and make a pseudo-decent program (albeit probably filled with redundant code and broken coding standards), but with VB.NET you have to learn and understand the language in order to get the most out of it. Complaining that VB.NET isn't good because it takes a little bit of effort isn't a strong argument at all. As for your last point.... you're..... well.... wrong. VB.NET makes development much faster. With the new OOP style of VB, you can do what you need to do in a much shorter time than with VB6. You just need to know how to do it. Just take a look at C++, the most popular language for large-scale apps; you think it's easy making programs like Word or Adobe Photoshop in C++? A program like Photoahop would be unthinkable in VB6, but attainable in VB.NET. You just have to put some effort into it.
-
Just remember that the constuctor and Load event are not the same. Load fires before the form is shown for the first time, and the constructor is fired when the form is initialized (Dim frm As New Form2).
-
Well, initialization code would fire on the Dim frm As New Form2() line, instead of on the showing of the form. In this case, that wouldn't really matter because they are right beside each other, but in some cases, it could throw some things off. But to try it, expand the 'Windows forms designer generated code' region, and look for the constructor: Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End SubAnd then try adding your Form2_Load coad underneath of that second comment.
-
Try this:'In Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm As New Form2() frm.ShowDialog() End Sub 'In Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MessageBox.Show("Wheeeeee!!! I am Form2_Load's code!") End Sub
-
That's a very bad way to do it for a few reasons. Number 1 is that Shell is part of the VB6 compatability library (bad). Number 2 is that Wordpad can be in a different location depending on the OS. The best way to do it is like this: Process.Start("pathtodocument")It will not necessarily start in Wordpad (possible MS Word, or something), but it will start in whatever program is assigned to the file type of your document (as if you double-clicked it in My Computer). [edit]Remember not to hardcode the path to your document. To get the path that the application is running in, use this: Application.ExecutablePath[/edit] [edit]Also, don't use On Error any more! With .NET, you can use the Try...Catch block. For example: Try Dim i As Integer i = 5 / 0 Catch ex As Exception 'there was an error; in this case, it'll be division by zero 'use the ex object that was just initialized to get information about 'the error. End Try[/edit]
-
What about creating instances of classes that you create dynamically using the CodeDom? Wouldn't you have to declare an Object variable, and then use the Assembly.CreateInstance method to initialize it? Wouldn't that be considered late-binding, and therefore, not supported by Option Strict?
-
In response to your "why then do the help files infer that it is still an available option" question: Well, the FileSystemObject does still exist in Windows, and therefore, with some coaxing, it's probably usable in .NET. It's not recommended, (even in VB6 it wasn't recommended; it's mostly for VBScript), but it's possible. The help files probably show some documentation for it for backwards compatibility purposes, though I find most of Microsoft's compatibility stuff useless.
-
Don't use the FSO in .NET. There is a System.IO namespace which contains all kinds of file access functions. Search your MSDN, as well as EliteVB for documentation on how to use it.
-
There isn't. The DrawRectangle method is the best way to do it.
-
Well, to split a string up into its separate words, you can use the .Split() function of the string. You'll need to define a list of possible word seperators as well, so something like this: Dim seperatorList() As Char = _ (".,?-" & ControlChars.CrLf).ToCharArray() Dim wordList() As String Dim wordsToSplit As String = "the quick brown fox jumps over the lazy dog" 'Splits the words up using all of the possible word seperators. 'You'll need to add to the seperator list yourself, because it's by 'no means a complete list, but suitable for demo purposes. wordList = wordsToSplit.Split(seperatorList) This will fill the wordList array with all of the words in the sentance "the quick brown fox jumps over the lazy dog". Now, you can loop through each string in the array and check the lengths using the .Length() method. Dim temp As String For Each temp In wordList() 'Use temp.Length to get the length of the word. Next To get the total number of words, use wordList.Length.
-
fixed array inside a structure
Volte replied to SleepyTim's topic in Interoperation / Office Integration
I'm not 100% sure about what your problem is, but you may want to try declaring your Integers as Int16 in your structure, if it's the number of bytes you're worried about. I believe that Integers in VB.NET are the same as Longs in VB6, and Int16 represents the original Integers from VB6. I could be mistaken though. -
You could make a Sub Main to initialize your program with. For example, set your startup object to Sub Main from the project properties, and add this class: Public Class Init Public Shared Sub Main() If findPreviousInstance() Then Application.Exit() Else Dim frm As New Form1() Application.Run(frm) End If End Sub Public Shared Function findPreviousInstance() As Boolean 'do your check End Function End Class
-
It seems to be that if you specifically specify the fonts of the textboxes, they will be the same size. Assuming you are using standard <input> tags, <input type="text" size="20" style="font: 10pt Courier New" name="user"><br> <input type="password" size="20" style="font: 10pt Courier New" name="password">That works for me.
-
You can get the handle of the application's main window by using the .MainWindowHandle property of the process you found. I don't know, but I assume the first one started will be 0 in the array of returned processes.
-
I found this in the MSDN.' Visual Basic .NET Function PrevInstance() As Boolean If Ubound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then Return True Else Return False End If End Function
-
It would only parse out , correctly if the current locale was set to something that used , as decimal seperator. Try setting your decimal seperator to , and trying it again.
-
Wow. I didn't know that was even possible. :) Thanks div. ;)