|
<br />
<br />
<% @Import Namespace="System.Data" %><br />
<script language="vb" runat="server"><br />
Dim searchword as String<br />
Dim pls as New DataTable()<br />
<br />
Sub Page_Load(sender as Object, e as EventArgs)<br />
BuildDataStore()<br />
<br />
completeData.DataSource = pls<br />
completeData.DataBind()<br />
End Sub<br />
<br />
<br />
Sub BuildDataStore()<br />
Dim dr as DataRow<br />
<br />
pls.Columns.Add(new DataColumn("Results", GetType(String)))<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "If only God would give me some clear sign! Like making a large deposit in my name at a Swiss bank."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Is sex dirty? Only when it's being done right."<br />
<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "On the plus side, death is one of the few things that can be done just as easily as lying down."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "I took a speed reading course and read 'War and Peace' in twenty minutes. It involves Russia."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "To *you* I'm an atheist; to God, I'm the Loyal Opposition."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Sex without love is an empty experience, but as empty experiences go, it's a pretty good empty experience."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "It's not that I'm afraid to die. I just don't want to be there when it happens."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "What if everything is an illusion and nothing exists? In that case, I definitely overpaid for my carpet."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Interestingly, according to modern astronomers, space is finite. This is a very comforting thought-- particularly for people who can never remember where they have left things."<br />
pls.Rows.Add(dr)<br />
<br />
dr = pls.NewRow()<br />
dr(0) = "Eighty percent of success is showing up."<br />
pls.Rows.Add(dr)<br />
End Sub<br />
<br />
<br />
Sub BindData(strQuery as String)<br />
searchword = strQuery<br />
<br />
Dim dv as DataView<br />
dv = New DataView(pls)<br />
dv.RowFilter = "Results LIKE '%" & Regex.Replace(searchword,"'","''") & "%'"<br />
<br />
SearchResults.DataSource = dv<br />
SearchResults.DataBind()<br />
End Sub<br />
<br />
<br />
Function Highlight(Search_Str as String, _<br />
InputTxt as String, _<br />
StartTag as String, _<br />
EndTag as String) As String<br />
<br />
Dim ResultStr As String <br />
Return Regex.Replace(InputTxt, "\b(" & Regex.Escape(Search_Str) & ")\b", _<br />
StartTag & "$1" & EndTag, RegExOptions.IgnoreCase)<br />
End Function<br />
<br />
<br />
Sub searchQuotes(sender as Object, e as EventArgs)<br />
BindData(SearchTerm.Text)<br />
SearchResults.Visible = True<br />
End Sub<br />
</script><br />
<br />
<style type="text/css"><br />
.highlight {text-decoration: none;color:black;background:yellow;}<br />
</style><br />
<br />
<form runat="server"><br />
Text to Search: <asp:TextBox id="SearchTerm" runat="server" /><br />
<asp:button runat="server" Text="Search Woody Allen Quotes"<br />
OnClick="searchQuotes" /><br />
<p><br />
<asp:DataGrid runat="server" id="SearchResults" AutoGenerateColumns="False"<br />
Visible="False" ShowHeader="False"><br />
<Columns><br />
<asp:TemplateColumn><br />
<ItemTemplate><br />
<%# Highlight(searchword, DataBinder.Eval(Container.DataItem, "results"), "", "") %><br />
</ItemTemplate><br />
</asp:TemplateColumn><br />
</Columns><br />
</asp:DataGrid><br />
<p><br />
The Data Being Search<br />
<asp:datagrid runat="server" id="completeData" ShowHeader="False" /><br />
I imported this code in Visual studio.net and change on click events and other thing that they have to change but
there is a problem ! Framework said that error BC30390: 'webapplication1.webform1.searchwords' is not
accessible in this context because it is 'Private'.
any idea ?
onezero@gmail.com
|
|
|
|
|
First off, this questio njbelongs in the ASP.NET Forum, not VB.
Yeah, you can't use the variable searchword outside the <script> block. When you called Highlight , you tried to use a variable that was not visible outside the script block.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how can i connect the microsoft chart control with a table in the db so i can plot the data on the MS chart control.
|
|
|
|
|
Hello
I want to preview MS office documents (word and excel) on windows form using VB.NET (example how to do this can be in any language, but VB id preffered ). Somewhere I have found, that this is done using Microsoft Web Browser component (SHDocVw.dll). Well, this seems to almost work, but...
Problem #1:
When I try to open an office document caling webBrowser.navigate("file:///some_document.doc") , it pop-ups a dialog offering me to open or download this document. There is a check box, so next time I try to open this kind of documents, it will not ask me, but display it.
Problem #2:
Vhen a document is opened in a web browser, it is editable. Well, this is normal, because there is an instance of MS word opened in the web browser.
What I need:
I need to show (preview) an office document in a windows form. The "preview" meens, it must be read only and not bothering users with some dialog if they want to download or open it.
Thanks a lot for any help.
Satano.
|
|
|
|
|
i have this code and i want this as a windows service.
i like this to execute every 20 secs
Dim olapp As New Outlook.Application
Dim olNs As Outlook.NameSpace
Dim myrecipient, myfolder
Dim myitems As Outlook.Items
Dim mymail As Outlook.MailItem
Dim myitem As Object
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
Dim cmd As New SqlCommand
olapp = CreateObject("Outlook.application")
olNs = olapp.GetNamespace("MAPI")
myrecipient = olNs.CreateRecipient("someusername")
myrecipient.resolve()
If myrecipient.resolved Then
myfolder = olNs.GetSharedDefaultFolder(myrecipient, Outlook.OlDefaultFolders.olFolderInbox).Items
End If
myitems = myfolder
myConnection = New SqlConnection("Data Source=.....")
myCommand = New SqlDataAdapter
myitems = myitems.Restrict("[Unread] = true")
myConnection.Open()
For Each myitem In myitems
On Error Resume Next
cmd = New SqlCommand("Insert into NewMessages (EntryID,SenderName,Subject,ReceivedTime,Body,UnRead) values(@EntryID ,@SenderName,@Subject,@ReceivedTime,@Body,@UnRead)", myConnection)
cmd.Parameters.Add(New SqlParameter("@EntryID", SqlDbType.Variant))
cmd.Parameters("@EntryID").Value = myitem.entryid
cmd.Parameters.Add(New SqlParameter("@SenderName", SqlDbType.NVarChar, 100))
cmd.Parameters("@SenderName").Value = myitem.sendername
cmd.Parameters.Add(New SqlParameter("@Subject", SqlDbType.NVarChar, 1000))
cmd.Parameters("@Subject").Value = myitem.subject
cmd.Parameters.Add(New SqlParameter("@ReceivedTime", SqlDbType.DateTime))
cmd.Parameters("@ReceivedTime").Value = myitem.ReceivedTime
cmd.Parameters.Add(New SqlParameter("@Body", SqlDbType.Variant))cmd.Parameters("@Body").Value = myitem.Body
cmd.Parameters.Add(New SqlParameter("@UnRead", SqlDbType.NChar, 5))cmd.Parameters("@UnRead").Value = myitem.UnRead
cmd.ExecuteNonQuery()
Next myitem
myConnection.Close()
olapp = Nothing
olNs = Nothing
myrecipient = Nothing
myfolder = Nothing
myitem = Nothing
myitems = Nothing
myrecipient = Nothing
i've already created a service for this one but, on its first start, it extracts unread mails, but when new mails come, it does not extract anything and when i checked on the application log it says, Microsoft Office 11 - Rejected safe mode action - Microsoft Outlook. on the system log: DCOM - The server {0006F03A-0000-0000-C000-000000000046} did not register with DCOM within the required timeout. I already uninstalled and killed the service but i'm still getting this errors on the eventlog. why is this so? i think i messed everything up. :'( please help me resolve this..
|
|
|
|
|
hi
is it necessary to have smtp server on that machine to send mail.
suppose i dont have the smtp server than how can i send mail through code(dont tell me the code just what process should be followed).
|
|
|
|
|
Private Sub showMonth()
MonthlyCalendar1.FirstDate = d
txtMonth.Text = DatePart(DateInterval.Month, d) & "," & " " & DatePart
(DateInterval.Year, d)
End Sub
The above code displays the month in a number format like 4, 2005. I want to know how to modify the above code to display the month in April, 2005 format. How should I do it? I have tried select case but I get an error saying that I can't combine 'Date' with an 'Integer'.
|
|
|
|
|
Try the command Format
Here dt is a datetimepicker control
Format(Me.dt.Value, "d/MMM/yyyy")
|
|
|
|
|
I'm interested in adding custom columns to a datagrid (not ASP), and am using sample code I found, which illustrates how to do so with a combo box. The sample works fine. But, when I substitute code to implement a DataGridTextColumn with either a NumericUpDown or DateTimePicker, I run into at least one problem. That is, the control in the columns works well until the user pans the grid (scrolls horizontally). The custom control remains in the same location relative to the grid, rather than moving with the column. I've looked at the code that implements the combo box and, except for the differences in the custom control I'm adding, I can't tell why the combo box moves as it should and the others don't.
Any ideas?
Thanks in advance
Dan
|
|
|
|
|
In my vb app, I have a sql connect string in my publicModule. when the user install the app, it will ask the "Initial Catalog" and "Data Source" value, then open the app. if the user input the wrong value, then the app can't open the sql data, how can I check the two value are matching in the sql data? and what's the best way to put the sql connection string in my app.
I created a registry key for the two value. Is it the best way? how can I check the registry key if it's not exist?
Lisa
|
|
|
|
|
When your application starts, it should check to see if there are values in the appropriate storage locations for your Inital Catalog and Data Source. These could be in the Registry or in a config file somewhere. If the values are not there, then your app should ask for them.
Once you have them, either input by the user or fetched out of the saved config, you can try and connect to the database and run a small query. If any part of the query process fails, then you can be pretty sure something is wrong and the code should return any errors to the user and either ask for corrected, or alternate, connection information or quit.
In my work, I like to setup a stored procedure in the database that returns a value specific to that database. For example, returning a string that specifies what the database name is, it's code version and its schema revision, like "TSEC ver:2.00 schema:6.30". This way, my code knows that this database is the correct one it should be working with, regardless of what the Data Source name is(!) and it gets additional information that the application might need. Such as taking into account dealing with an older version of a database's procedures or dealing with a minimum database version that's supported by the code.
Currently, Microsoft recommends NOT using the registry to store application configuration values, such as a connection string, but instead, recommends using .config files. Rocky Lhotka wrote a very good article for MSDN, found here[^], that explains configuration files and how to read and write them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi , I have a homework to do in VB 6.0 but I couldnt even figure out TextBox's Text Property
when I code ..it gives an error as "Argument Not Optional"
I found text Property textBox1.Item.Text , but the error givenn..Why ?
if I code , textBox1.Text it couldnt find such a property...
If anybody could help me , I would be greatful..I need a Telephone Book in Vb 6.0..
if somebody has an old project like that...please forward to bcambel[at]gmail[dot]com
I did the project in VB.NEt but teacher has refused it , and insist on me to do the project in VB , please hellppp..I am begging
Anyways , thanks in advance!
|
|
|
|
|
Wait a minute! You said you wrote the application in VB.NET, yet you can't figure out the Text property on a VB6 TextBox???
The TextBox in VB6 works almost entirely the same as the TextBox in VB.NET...
Makes me wonder, did YOU REALLY write the VB.NET version or did you, like in your post here, just ask for it and someone, stupidly, gave you their VB.NET version?
Sorry, we don't do homework here. You have to write the code! And if you have problems with it, then we'll help. Noone here is going to just hand you their completed project so you can save your ass.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I wrote the VB.NET version! I know that both of the properties just look same! I told the problem .I dont force anybody to do my homework.I just ask...
If you dont believe , I could send you a bunch of projects that I did before..
Rather that behaving like the lawyer of the CP , if you know the answer , you may help!You dont need to accuse me ..Got it ?
|
|
|
|
|
I found the problem ,
Although I change the name property , some how its name didnt change..
2 more questions , how could I open a OpenFileDialog like in .Net ?
And is there an Xml support in Visual Studio 6 ?
|
|
|
|
|
Bahadir Cambel wrote:
Rather that behaving like the lawyer of the CP , if you know the answer , you may help!You dont need to accuse me ..Got it ?
LOL. Lawyers are not THAT bad ... LOL
|
|
|
|
|
Yes , I like them all(a big lie ) , esp the woman ones
|
|
|
|
|
If your teacher won't accept VB.NET and requires VB6, just leave the class, and find one where if you can't use a decent language, you can at least learn the latest version of a crappy one.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
If your teacher won't accept VB.NET and requires VB6, just leave the class, and find one where if you can't use a decent language, you can at least learn the latest version of a crappy one.
Christian,
You never answered my question: "What significant capabilities does C# offer that VB.NET does not?"
I could write an intelligent parsing algorithm to replace all the braces in your code and end up with the same programming language you so love to despise.
Face it. C# is pretty wimpy all-in-all. At least as wimpy as VB.NET. Plus VB.NET does not try to parade itself as a Java look-alike. ROTFLMAO!
If you want a challenge and real programming, hang out in the ATL or COM forums more often.
|
|
|
|
|
rwestgraham wrote:
You never answered my question: "What significant capabilities does C# offer that VB.NET does not?"
You're asking the wrong question. I never claimed that this was the case, at all. VB.NET is crap, not because C# has more capabilities ( this would make C# crap, as C++ can do more ). It sucks because it is dragged down by legacy 'features' that Microsoft were forced to provide to keep the VB6 monkeys happy. For example, any language that auto generates return values for you is creating far more opportunities for hard to find bugs than any C++ switch statement could create.
However, here's a list I keep on my desktop ( I didn't write it, but it covers most things I would mention, and I like how it's worded )
1. The absence of the "using" statement for calling IDisposable creates resource-hungry programs. VB programmers simply do not call IDisposable, or do not call it in a reliable way.
2. "Unstructured error handling". Aka "On Error Goto". Aka bad code.
3. "On Error Resume Next". Aka "On Error F**k off". This is one of my favorites: in case of an error, resume the execution point on the next statement. Lots of fun here.
4. "On Error Goto 0" and "On Error Goto -1". I'm yet to find a VB programmer who can tell the difference between the two.
5. The "Mid" statement. No, not the function, the statement. Isn't it a work of a genius naming a statement and a function with the same name?
6. "Modules". Aka "I don't need any stinking classes". Aka "I won't ever need thread safety"
7. The "With" statement. Aka "I don't need any stinking methods. I manipulate an object outside the class definition and I call it information hiding". Aka the "data class" bad code smell. Aka "deriving a class is too much work".
8. "Option Compare Text". Aka "I don't need performance when comparing strings"
9. "Option Explicit Off". Aka "There's only one type, the powerful Object". Aka "I want to give away performance because I'm lazy typing variable declarations". Aka "I don't want a compiler checking the variable names for me. If I mistype a name, just create another one for me, pleeeease."
10. "Option Strict Off". Aka "What? Why can't I just assing this string variable to this integer variable?"
11. The hidden return variable. All functions have a hidden variable that is named with the same name as the function. Don't forget to assign to it. In any code path. If you forget, VB choses a default value for you and won't warn you.
12. BTW, there are no warnings. And this is meant to be "a productive language?"
13. REM. It'd be fun seeing a program entirely commented using exclusively REM.
14. "Array Covariance". I'm yet to know a VB programmer who can tell me what's this (BTW, I know).
15. The "Like" operator. The syntax is incompatible with the .NET Regex syntax. Answer quickly: should "x**y" match "xy" and "xay"? The answer is none. Can you explain why?
16. The "Concatenation Operator". Quoting MSDN: 'Also, there is a special case in that Nothing is treated in concatenation expressions as if it were the empty string literal ""'
17. I'm yet to find a VB programmer who can declare a char constant.
18. x!abc. Aka x("abc")
19. Copy-in/copy-out semantics when passing an argument passed to a reference parameter and the argument needs to be coerced to the right type. It sounds complicated, huh? Don't worry about, unless you're using multithreaded code.
rwestgraham wrote:
Face it. I could write an intelligent parsing algorithm to replace all the braces in your code and end up with the same programming language you so love to despise.
Actually, VB.NET -> C# converters are commercial products, so there's more to it than that. Even then, they tend to import the VisualBasic namespace and use stuff like the excrable Iif, instead of ()?: syntax. I have a major project that I won on the basis that I could convert it to C# from VB.NET. It took a half day with a commerical converter, and then hand fixing all the references to the VB namespace. I've also worked on several VB.NET web sites that had been begun by other people. These experiences confirmed what I suspected all along - the basic problem with VB is that most people who use it should not be let near a program of more than about 50 lines, they just have no idea about structure, design, or anything else. The website I worked on had stored procedures in the database, and DB calls in the middle and web tiers. Many methods were generated more than once, nothing was done efficiently, etc.
Yes, some people in VB can code, many people using C++ cannot. However, the VB people who are ignorant generally can get something that looks good enough to ship, and therein lies the danger.
The basic problem with VB.NET is that it was modified to keep the VB6 crowd happy, and that it bears the name of a 'language' whose name is beyond redemption, both because of bad design, and because of a high percentage of ignorant users.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
1. The absence of the "using" statement for calling IDisposable creates resource-hungry programs. VB programmers simply do not call IDisposable, or do not call it in a reliable way.
VB.NET class can fully implement the IDisposable interface. It is very simple to do.
The next section of your "complaints" are all deprecated features. I use structured error handling only in VB.NET. All languages contain "features" that can lead to poor practices. This is hardly unique to VB.
I don't think you understand the context of using the With Statement at all. It is not used for manipulating class objects outside of the class definition. Rather it is a way to reduce the number of dot redirections that have to be interpreted by the compiler. Using With actually results in more efficient code because it eliminates unneccessary redirection evaluations when you plan to perform a number of operations on the same object. It does not break any rules of encapsulation as you seem to infer. It simply reduces the compiler overhead.
The "hidden return variable". I don't think you understand how this is actually used in practice. If you carry over VB6 practices, you never have to worry about any default values because VB6 required you to explicitly return a function value using this "hidden variable". If you use the NET syntax or explicitly returning a value using a Return statement the hidden varaiable is ignored. In either usage, the argument that this mystery varaible lurking around can result in hidden bugs just does not wash, because whether you use the VB6 syntax, or the Net Return syntax - and you have to use one or another, the possibility of this mystery varaible returning spurious results is just not a practical consideration.
No warnings? Well this might actually mean something. However, the vast majority of C++ code I have seen written either simply ignored warnings, or added compiler switches to suppress them. I would consider this a valid point, except that I've seen little evidence that the majority of developers actually act on warnings. So why bother?
REM - Come on. This is really reaching to just to find a list of faults. REM has been held over from the ancient days of Basic. I know of no one who actually uses it in any of the higher Vb releases. I mean what's the point? Why type REM when you can simply type a '.
Array Covariance - exists in C# as well. What is unique about this to VB.NET?
Writing multi-threaded code correctly requires advanced abilities that are beyond the skills of most programmers period. The first rule of multi-threaded code is that generally MT is not neccessary or advantageous, and often the drawbacks far outweight the advantages. I've written MT programs (in VB, wow what a concept) for IVR programs where you were requyired to support multiple callers on channels asynchronously. I've also written MT code in real time data collection systems for nuclear power plant instrumentation systems. Those are specialized applications. Anyone who is experienced in MT will tell you gthe first rule is "Don't MT in general". It is not a skill that most programmers really need to acquire in the first place.
etc, etc.
Ignorance is by no means defined by using one language as opposed to another. Ignorance is ubiquitous, period.
If you don't want to use VB, don't use VB. I guess my real question is what do you get from constantly bashing VB? Doe sthis provide some kind of "validation" or something? Focus on writing really good code in whatever platform you prefer, and that should fill any sort of "validation" void you seem to feel.
Being a "C# programmer" seems to lead to some imaginary feeling of superiority over a "VB.NET programmer". It's all stereotypical and delusional. A good programmer is a good programmer, and that should provide enough personal satisfaction to eliminate the need to actively seek out opportunities to express some imaginary superiority over other programmers simply because they choose to use a different platform.
Robert
|
|
|
|
|
rwestgraham wrote:
VB.NET class can fully implement the IDisposable interface. It is very simple to do.
So I *did* tell you something you can't do in C# ? It's sad, b/c I trust a C# programmer to dispose an object more than a VB programmer. The using keyword makes for nice code. You don't have it. Question answered.
rwestgraham wrote:
The next section of your "complaints" are all deprecated features. I use structured error handling only in VB.NET. All languages contain "features" that can lead to poor practices. This is hardly unique to VB.
Deprecated features that by and large are in VB because the VB6 crowd complained. Deprecated stuff that is in use today, I've seen he production code, on new VB.NET projects.
C++ has similar problems, for the same reason - C compatibility. That's where C# is better, it has no older language it needs to pander to. Name the 'features' unique to C# that can cause similar problems ?
rwestgraham wrote:
Writing multi-threaded code correctly requires advanced abilities that are beyond the skills of most programmers period
Perhaps. So what ?
rwestgraham wrote:
Ignorance is by no means defined by using one language as opposed to another. Ignorance is ubiquitous, period.
Did you read my comment ? I agree, and in C#/VB.NET the only dividing line is that most VB.NET programmers got there via VB6, which used to be the answer to the question 'what's the easiest way to write code for Windows'. The people coming to C# tend to be VB6 users who are real programmers ( not scared of a new language ), and people who come from C++, who asked 'what's the BEST way to write code for Windows'.
rwestgraham wrote:
If you don't want to use VB, don't use VB. I guess my real question is what do you get from constantly bashing VB?
Initially, because VB6 was crap. Since then, I've sufered at the hands of VB.NET monkeys, and it amuses me that people would choose a language full of 'features' that lead to bad code, over a new language that doesn't have these issues. I come into this forum to help people ( I know enough about the .NET framework that often I can ). Sometimes, my attitude towards VB comes through in my responses, but I'm not here trolling or anything.
rwestgraham wrote:
Doe sthis provide some kind of "validation" or something?
Not at all. I have my validaion, I've seen what sort of code the VB side of the world churns out.
rwestgraham wrote:
Focus on writing really good code in whatever platform you prefer, and that should fill any sort of "validation" void you seem to feel.
You're barking up the wrong tree here. If I pursue a conversation like this, it's because I'm interested to see if any VBer can explain issues like magic return values ( you dodged that one ), and because it makes me laugh. I'll go a long way in search of a one liner.
rwestgraham wrote:
Being a "C# programmer" seems to lead to some imaginary feeling of superiority over a "VB.NET programmer".
No, it means I'm using the best tool for the job. That's all. There are bad C# coders, and good VB coders. The bad VB coders ( i.e. the majority ) would actually be better off in C#, where ( for example ) the using keyword makes it less likely they will leak memory, or the error raised when they don't return a value in one control path doesn't become a nightmare to debug, because it compiles and returns a magic value.
rwestgraham wrote:
A good programmer is a good programmer, and that should provide enough personal satisfaction to eliminate the need to actively seek out opportunities to express some imaginary superiority over other programmers simply because they choose to use a different platform.
Hey, if you write good code in VB, good for you. You're choosing to drag your own name down by associating yourself with a language that's responsible for a world of crappy code. You're also bypassing the Microsot fast lane, and choosing to make things hard for yourself in regards to the issues I already raised. I have more than enough work, even though I refuse VB work ( or I offer to convert to C#, as I've done a number of times now, and fixed the rest of the code over time ). The few who knock me back are just more work for you, but I definately prefer a language that understands things like not evaluating both sides of an or statement if the first is false ( yes, I know that can be done now, why could it not before ? ). On a personal level, VB's verbosity makes it look like the coding equivelant of See Spot Run, but that's just me. That's certainly not why I hate VB as much as I do, I hate it because it's given incompetent people a fast track to writing terrible code, and I really don't comprehend why anyone who has any idea about programming would choose to be slurred by it, when C# is better for all the reasons I stated.
So why do you use VB.NET instead of C# ? Was it just comfortable for you ? You said you use C++, don't you find the VB synax annoying ? Does it really feel like programming to you ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Normally, I'd just sit back watch the pretty fireworks...
You're both really good at what you do. But in either case, I'm probably going to regret doing this...
Christian Graus wrote:
So I *did* tell you something you can't do in C# ? It's sad, b/c I trust a C# programmer to dispose an object more than a VB programmer. The using keyword makes for nice code. You don't have it. Question answered.
Actually, we do have it, in 2005. A bunch of the language changes made for 2005 were to fill in the gaps and align the language features more with C#'s features. This in NO WAY means that I think C# is better than VB.NET or the other way around! Just because a language has some bad features doesn't mean you should get lazy and use them. In my view, there's no excuse for writing bad code because you didn't recognize a bad feature.
If you don't keep up with modern features and practices, you shouldn't be writing code in the first place. I hate hearing these idiots (mostly MVP's too! ) who demand that VB6 be supported because of the installed base of code! If you're an MVP in VB6, great! Go make some money supporting the old crap instead of upgrading it.
Christian Graus wrote:
Deprecated features that by and large are in VB because the VB6 crowd complained. Deprecated stuff that is in use today, I've seen he production code, on new VB.NET projects.
Damn complainers! Throw them some Depends before they piss themselves! I'm an old VB5/6 guy too, and I was soooooooooo happy when VB.NET came out with some real error handling. I don't use any of that old crap anymore. But, really, most of what you listed is deprecated crap that only the whiney idiots would use anyway. It's those idiots who refuse to upgrade their skills that are cranking out crappy code. Yes, I know what On Error Goto 0 and -1 mean, and HELL NO, I've never used them...
Christian Graus wrote:
You're barking up the wrong tree here. If I pursue a conversation like this, it's because I'm interested to see if any VBer can explain issues like magic return values ( you dodged that one ), and because it makes me laugh. I'll go a long way in search of a one liner.
I love this one! "Magic return variables" have never caused me a problem. Either you understand that they're there and deal with them or you don't. In order to deal with them, you have to write proper code anyway. I for one, don't EVER leave a return value to chance, in any language. I've always used the Return statement and I've always set a default value as one of my first statements in my methods/functions.
In my humble opinion, code is code, good or bad. It doesn't matter what language it's written in. As a universal law, no matter how perfect, or bad, you think any language is, the universe will always generate an idiot, to use it the wrong way.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
first of all, good discussion you had with CG, I enjoyed it a whole bunch!
Dave Kreskowiak wrote:
"I for one, don't EVER leave a return value to chance, in any language. I've always used the Return statement and I've always set a default value as one of my first statements in my methods/functions."
More often than not I take advantage of the fact that the VB compiler returns the default value of a function's return type in cases where one is not provided. Why you ask? Well, it's just handy on occasions, especially during the dreaded task of UI development, where my focus is just to program against an interface, forgetting about all the implementation behind that interface. I know all I have to do is just add that one line of code you say you always add, but I just don't even worry about that, rather I just define the interface I want to work against and implement it later. I'll admit I have experienced some debugging issues as a result of doing so; that's why I wish the compiler would treat the issue as a warning, but not an error. Also, another area where I heavily use this behavior is when creating "abstract base forms". I'm sure you know that the form designer requires that the base form have a parameterless public constructor; otherwise, it blows up. Well, then how do you create an abstract base form to be used with the form designer? Well, you can't, at least I haven't been able to. So what I do is just create a non abstract base form with a series of virtual methods that don't return anything rather raise an exception when called directly, the intent being that the derived form needs to override them so that any template methods work OK. Again, I know, I know, I should just add that one line of code you add, but what can I say, I just don't, and in this case, why should I? So really, I have to disagree with you and CG. CG says it's just straight out bad, you say it's OK but you make sure never to fall to it, I say it's OK always, but that compiler should give a warning.
Finally, I once asked CG the same question, that is, what's his problem with VB. At first I just couldn't understand, but then I tried to put myself in his position of having to go through the painful task of having to work on sh*tty VB code and then his feelings seemed quite clear, although his famous words "VB.NET is crap" always make the hairs on my arms stand up in fury .
Thanks for the discussion
|
|
|
|
|
Dave Kreskowiak wrote:
Just because a language has some bad features doesn't mean you should get lazy and use them. In my view, there's no excuse for writing bad code because you didn't recognize a bad feature.
I agree. My point is that, in general, there are more people in VB land that are likely to use bad features, and C# is better *because* the bad features are not there. I've written good VB code, but I had to do it by building on VERY bads VB code, worse code than it would be possible to write in C#.
Dave Kreskowiak wrote:
It's those idiots who refuse to upgrade their skills that are cranking out crappy code.
And in a world where you inherit projects from other people, the availability of those 'idiot features' are where the problem lies.
Dave Kreskowiak wrote:
I for one, don't EVER leave a return value to chance, in any language.
I would also set a default return value in the first line of code. But it's just one more thing to keep in mind when you're trying to figure out why someone elses code just plain doesn't work. And it's stupid.
Dave Kreskowiak wrote:
In my humble opinion, code is code, good or bad. It doesn't matter what language it's written in. As a universal law, no matter how perfect, or bad, you think any language is, the universe will always generate an idiot, to use it the wrong way.
I agree, totally. However, it's my experience that the universe generates more VB idiots, that code I've had to build on in VB is invariably terrible, code I've had to build on in C# and C++ is usually pretty decent.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|