Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. First off, I'd use the Microsoft.VisualBasic namespace to do the compare - I know of know built in way to do this. A simple function could be coded yourself that I'm sure would be fast enough for your needs. Make sure to include Microsoft.VisualBasic.DLL. string s = "hello WORLD"; int i = Microsoft.VisualBasic.Strings.InStr(s, "L", Microsoft.VisualBasic.CompareMethod.Text); int i2 = s.IndexOf("L"); Variable i will be 3 (remember that VB started counting at 1). Variable i2 will be 9. I think the real question everyone was trying to get out of you was, what is the end result of using IndexOf - what are you doing? You started to answer this with "takes user input that can be in any case, and I need to replace certain words" but that's like putting the comment "Incremet i" for the line of code i++. What is the nature of the string you're replacing? For example, is this data from a file or something a user types? Are you doing a bad word filter, or something like a code lookup (replace HOND with Honda)? No one uses IndexOf just because they like knowing indexes of characters in strings - they're trying to accomplish something "bigger". For example, using IndexOf usually means locating a piece of a string inside of another string. A regular expression can do this for you pretty easily. A sample: Suppose you have a string like "ABC, 123, Hello World" and you want to get each of these strings out. You COULD use IndexOf to find each comma. You might also use the Split function. You could also use Regular expressions to get out each chunk in a named group - think of it like a small data parser that gives you a DataTable with columns. It's slower, but would be much more readable in the end (and that means more maintanable). -ner
  2. Ah, JoeMamma IS back. :) Everyone likes good advice, Joe. But, please keep the flamatory remarks to a minimum. Flaming the Experts from another forum isn't productive for anyone. If your goal is to point out that the Experts are wrong on certain accounts (or just plain wrong ALL the time), then let them know. If you have time to mention it over here then you have time to mention it over there where all could benefit. Good: Pointing out specific problems, such as their tips on using a FlexGrid. Bad: Calling VB.NET "vb.sux". VB.NET is a great language with great tools, just like C# or any other high level language. No point in bashing a language just so you can get banned again. -ner
  3. Passwords embedded anywhere, encrypted or not, for a mid to large sized project is just stupid programming - or stupid engineers. Here's a simple way to keep the password secure: Limit access to the DB through stored procs. Create a trusted user account that only has access to stored procs. Assign the webserver to use this user account as a trusted connection. The connection string just has "...Trusted_Connection=Yes". No userid, no password. If you put the SQL server on its own domain, you've essentially "hidden" the SQL box and locked it down. Now that's just one architecture that's pretty secure - there are lots of books on the subject. The bottom line is that putting a password on a client machine, encrypted or not, is just a VERY bad idea. If lack of security weren't reason enough, if you embed a password (or even something like a server name) in an executable, you're asking for a maintenance nightmare. If you find that password compromised, you have to send out new EXEs - which is kinda pointless since that's probably where the password was stolen from in the first place. Encryption has it's purposes - but not in the realm of hiding a password. If you put anything on the client box, you have to assume someone is going to be a jerk and decrypt it. As Michael Howard put it "All input is evil". So are users. You'd better think that at least, when you're writing your code. -ner
  4. You're right, my goof - I think I was thinking he still wanted just one username and that even with a sub-select he'd still want a TOP 1 or similar. -ner
  5. Here's another way to get the youngest person - this is SQL Server syntax, other languages use different syntax: SELECT TOP 1 username, Age AS YoungestMember FROM Users ORDER BY Age ASC kejpa's method works if you want all people, by age - not just the youngest. The subselect method works fine though you can't control which user you get back other than one - more or less randomly - from the users that match the youngest age. If 32 people are all 14 years old then you'll get one of the 14, but you can't control which. The "TOP 1" with ORDER BY will let you have a little more control, if it's needed. Performance of each? Kinda depends on the amount of data you have and disbersement of values. The ORDER BY is going to want to try to use an index, as will the MIN() on the subselect. Those types of operations will vary depending on the data being looked at - in this case Age. The SQL engine has an Optimizer that evaluates all the SQL and creates a plan for how it thinks it can get to what you want the fastest. If you've got on the order of a few thousand or less users you'll probably be fine. -ner
  6. In C#, checking if a table is null would cause an exception. You should use the Contains method: If dsDataset.Tables.Contains(dtName) Then dsDataset.Tables.Remove(dtName) End If -ner
  7. I would ask why you want the class - to pass the test or to learn the selected topics? If I were the boss and asked to shell out some money to train my people, I'd want to make sure they want to learn the topic (and of course that it will help them at their current job), not just pass a test. If you want to learn the topics, I'd investigate the classes from that perspective as there may be others that cover more and/or cost less. -ner
  8. I'd be up for a Visual Studio forum - could have more than just bugs, such as tips and tricks or just "how do I...?" type of questions. Seems like there are enough questions to warrant one, especially if questions about add-ons and such were directed there. Only two issues: 1. I think that some forum users may not "know" the difference between Visual Studio, .NET framework, and the language of choice - because they're so tightly integrated. Not a big deal, just some work for the mods to move posts around. 2. I wonder if there's an Admin around that can add the new forum? There was talk about a "Reviews" forum awhile back that sounded good, but no one to create it. -ner
  9. I'll note that if you used previous versions of Visual Studio, the XML for a dataset was pretty straightforward. The newer XML is vastly more complicated, at least the code generated by C# express. I'd hate to go in there manually anymore :) -ner
  10. Just a suggestion - property names are generally nouns, not adjectives. You could use an adjective and noun - maybe something OptionalColor. In six months, you'll be typing [class]. and the intellisense is going to show you "Optional" and you'll think - what goes in *there*?? -ner
  11. In VS2002 and VS2003 there was a Tab - you couldn't miss it. I just tried creating a new dataset in C# Express - no such tab. I did some poking around, but I can't find a way to view the XML other than opening the XSD in notepad or similar. -ner
  12. Both the technical preview and the Express products are pretty buggy, in my opinion. I've done some pretty standard stuff and it craps out on me with "Catastrophic Error" in a messagebox. Yikes! I haven't installed any of the newer betas, other than the Express product. Still looks very promising, but too early/buggy for me to do any real work or invest much time yet. -ner
  13. To check for the table before you create, you need to check the sysobjects table. Below is a simple check: if 0 = (select count(*) from sysobjects where name = 'typicals') begin CREATE TABLE typicals (typical varchar(200),typicalnr int) end I'd leave off the semicolon, only because it's not necessary. If you want a more robust "object exists" check, use Enterprise Manager to script out the create/drop statement for you. It does a lot more to check if a table exists including checking the type of the object in the sysobjects table. -ner
  14. Try this: deviceInfo selectedDevice = (deviceInfo)cbTask.SelectedItem; Then you can use selectedDevice as a true deviceInfo object. -ner
  15. I've seen demos of Team System and we've got a small version of the Beta installed at work to "play around" with. It looks VERY promising. The new XNA version of Visual Studio builds on Team System. The extra features look mostly tailored to the content portion of Game Development. Most visual studio projects do not have much in the way of content. Maybe some images or other resources, typically embedded in the DLL/EXE or included as support files. Game development is very big on content and, from what I understand, a major headache to manage. Developers have good tools for managing code changes - version tracking, a library, merge capabilities, etc. But the content portion of a project is hard to work with. There are a couple of other game content/code products out there so I guess MS is just trying to edge into that area. Makes sense now that they have the XBox product. Along with Team System, this sounds promising for Game Developers in a team - not so important for single developers, the hobbyists. Team System integrates bug tracking, source control, task items, etc. into one environment. -ner
  16. If this is a windows app, you can catch the event for Application.ThreadException, something like: static void Main() { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); } private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { // Handle e.Exception } -ner
  17. Even if you choose the VB6 keyboard mapping, it's just a default. All commands can be remapped to any keystroke through the Tools, Options menu. -ner
  18. These keystrokes are the defaults for C#, probably VS. If so, they should work with VB.NET: F12: on a line of code, this will "go to definition" Shift F12: on a function name, will "go to first reference". Ctrl - : (that's hold control and press minus) Go back to previous cursor position Ctrl Shift - : Go forward to last cursor position. VS keeps track of all cursor movement, more or less, since you open VS. Pressing Ctrl - multiple times will keep cycling backwards to where you were before. With the 4.x drivers for MS mice, you could assign a keystroke to any button, even per application. I used to have my left thumb button mapped to Ctrl - for Visual Studio so navigating back was as easy as pressing the side button on my mouse. They took out this lovely feature in 5.x and I'm too lazy to look for a freebee driver. :( -ner
  19. I wouldn't shoot for solving all. Even if you pick out the first 800, I think it's safe to assume that most will be at least 2 hours - that's 1600 hours or roughly 200 days (8 hours/day). That's a full year of doing almost nothing but solving these problems... I'm a nerd, too - math and computers. -ner
  20. If you want to use MSDE, be prepared to read quite a bit of the README that comes with it. Its install is command line based and if you want a secure password or if you want to turn off network support (so people on the internet can't see your copy) and other options, you need to read and set some options. I use MSDE at home for my little projects. I use the Express version of Visual Studio (for C#, still in beta). It has a Server Explorer piece that allows creating database, tables, columns, etc. It works well enough for me but my needs are small. There's also MySql, which is free (I think). I've never tried it, but I know it's fairly popular and well supported - it might be a better alternative to FoxPro as well. I haven't checked recently, but MS does phase out some products. You might check on FoxPro just to make sure you don't spend too much time learning it only to find it's being removed from MS's support. While SQL is mostly the same, every DB engine has slightly different syntax. For example, to get the first 10 rows in SQL Server: SELECT TOP 10 * FROM Table1 In MySql: SELECT * FROM Table1 LIMIT 10 (or something like that) FoxPro probably has its own special syntax... Have fun! -ner
  21. If mookie is still around, I'd STRONGLY suggest sticking with VB.NET. I'd concentrate more on learning good programming habbits (OO programming, using patterns, refactoring code, effective comments, etc.), the .NET framework, etc. See the summary below if you want to skip this post When you're starting out programming there's a strong desire to learn other languages. Many VB 6 programmers had "C++ envy", but stuck with VB. Many VB.NET programmers feel a "C# envy" and may tinker with C#. In all honesty, stick with what you know. Keep this thought in mind whenever you feel the urge to drop one language and switch: are you switching because your current language lacks something you use a LOT, or are you switching for some other reason? Bad reasons to switch: * The other language has one cool feature which you might use, but probably not (ie, pointers in C++) * The other language makes it easier to do some things (A robust Switch in VB.NET looks nice, but you may not use it but once in a blue moon) * The other language has better IDE support (VB.NET has better support for adding event handlers - from the code window). If you do this a LOT, maybe a reason to switch. Summary: I think a C# programmer can come up with reasons to choose C#, VB.NET can come up with a list of reasons to choose VB.NET, and C++ programmers can come up with a list of reasons to choose C++. An experienced programmer knows not to ask what language is "best" or "right". A "newbie" programmer should probably stick with what they know and ignore the "feature envy" of other languages. -ner
  22. FoxPro is definitely still in use! But, if you have no requirement to use it and not familiar with it, I would start with Access. If you feel you're not so "junior", mySql or MSDE (harder to setup but more robust than Access) might suit your needs more but Access works for many small projects. SQL Server is always an option, but it's very pricey. There is a free version if you're just writing test code. This doesn't really answer what you want - how to get FoxPro. From what I recall, it came with Visual Studio 6 (mentioned above) but not with .NET. -ner
  23. I'm guessing that you need to set a "startup folder" for the process. Meaning, your program isn't running from "j:\mame" so you need to tell mame to run from that folder. When MAME starts up, it's trying to locate other files in YOUR program's folder rather than in "j:\mame" and it's "crashing" out. Note: I see that you're providing the full path to the EXE, but that's not the same as "the folder where the program is running from". -ner
  24. I didn't read about the tank thing, but I liked the line below the 2002 penny under "Our customer's Advice": 1 person recommended Nickel from 2003 instead of 2002 Penny Probably how you found the second link... -ner
  25. Maybe I missed the original question, but he's looking at a class, not an interface and the class is just implementing the property Enabled (as required for the IScrollBar interface). I don't know the VB syntax for sure, but that's my guess: Private Function Windows.Forms.Edit.IScrollBar.get_Enabled() As Boolean Implements IScrollBar.get_Enabled Return MyBase.Enabled End Function So the property Enabled is being implemented in whatever class he's looking at. This covers the IScrollBar's Enabled property which must be implemented. Maybe I'm missing it though. I wonder what he's disassembling, since IScrollBar doesn't appear to be a Windows related interface. -ner
×
×
  • Create New...