

InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
2451. |
Solve : programming issue in excel? |
Answer» Hi! |
|
2452. |
Solve : What's the best way for a newb to learn Java?? |
Answer» And I mean a total Newb. I have no coding EXPERIENCE what so ever. I want to learn to write android apps and I want to learn the right way. By learning the language not using some GUI that does it for me but gives me no code. |
|
2453. |
Solve : Help with Space Shooter in C++ and SDL!!!? |
Answer» Hi. I'm currently in the process of writing a space shooter type-of-game in C++ using the SDL API. I have everything working great, but I'm having some trouble getting my spaceship to fire a laser. I know how to do this, but I'm using three different CLASSES that all inherit from each other, and I can't get anything to work from my Laser class. This is the error message I get: |
|
2454. |
Solve : php deleting file? |
Answer» hi, in my application i would upload a file to a certain directory then after i would be able to DELETE it but then a got a warning Under Windows System and Apache, denied access to file is an usual error to unlink file. Not sure if that works. Anywhoo, is just an FYI.Quote from: http://www.php.net/manual/en/function.unlink.php#85938 To ANYONE who's had a problem with the permissions denied error, it's sometimes caused when you try to delete a file that's in a folder higher in the hierarchy to your working directory (i.e. when trying to delete a path that starts with "../").HY. I runned into that *CENSORED* problem too. And after days of searching I finally found this software: *SPAM*. It's GREAT. You can find it here: http://www.deletelongfile.com |
|
2455. |
Solve : I'm trying to build my own RPG-style game? |
Answer» I have some experience with a couple different programming languages, but very little with creating anything resembling a sophisticated, or even friendly, interface. I've heard that Flash is a reasonable approach, but I know ZERO about programming in/with flash. I am also only self taught... If you want to create a game with a 'classic' feel, then use QBasic. That doesn't make a whole lot of sense... what is a "classic" feel and how does QBASIC provide it?Quote That doesn't make a whole lot of sense... what is a "classic" feel and how does QBASIC provide it? The games that you develop using qbasic run under DOS. The PC speaker and 320x200 VGA/CGA graphics make it seem like a classic DOS game that was made in the early 90s.Quote from: Linux711 on November 08, 2010, 10:54:55 AM The games that you develop using qbasic run under DOS. The PC speaker and 320x200 VGA/CGA graphics make it seem like a classic DOS game that was made in the early 90s.Doom was made in the early 90's and certainly can be called a classic DOS game. However I fail to understand how QBASIC even comes close to approximating that experience. Additionally, it would seem that you are not describing "classic" DOS games from that era as much as you are describing the crap of the crop of the time. Just because something creates "DOS games" doesn't instantly give those games a classic feel. That has to be added intentionally. The only games using the PC speaker after around 1993 were not "classics" as much as they were shareware cruft. Additionally, it sounds more like you are using "classic" to refer to text-based RPG games, which is a rather large generalization, and in no way requires a console interface. Either way, suggesting anybody use QBASIC for any purpose is stupid. The assumption here is that if they produce a game, they want to get other people to try it as well. QBASIC cannot compile so they will have to distribute it as source, and hope anybody who wants to try it is not running a 64-bit OS and KNOWS how to get QBASIC and knows how to use it to start the game. This directly flies in the face of the fact that they implicitly want to create "anything resembling a sophisticated, or even friendly, interface." Which undebatably QBASIC doesn't even begin to provide. Quote from: icedragon668 on November 07, 2010, 07:54:48 PM I have some experience with a couple different programming languages, but very little with creating anything resembling a sophisticated, or even friendly, interface. I've heard that Flash is a reasonable approach, but I know ZERO about programming in/with flash. I am also only self taught... Flash would be a good option, of course you would need to have Flash in order to work with it. I won't lie and say it's "simple" to make a game, but I've made a few simple games, such as a frogger game, pretty easily, so it can't be that bad. The language is called "ActionScript" and seems pretty powerful, if it is a bit confusing syntax-wise at times. Barring that, I'd go with one of the .NET languages. I'd stay as far away from C and C++ unless you are planning to write an Operating System, since they will unnecessarily complicate things. Arguments about "being more portable" are also baseless, as in many ways C# and .NET are more portable to Linux then C or C++ are. (C & C++ are "source compatible", which means you would have to recompile it for each platform; and even then it's only theoretical, since you will almost certainly have to make changes to account for the different systems. With .NET, as long as you avoid using the various Windows-only framework components (which sort of necessitates creating a Console game) you can run it on Linux using Mono. Of course, you could also get a similar and even better effect with Java, which is quite similar in many ways. The advantage here is that you can both use graphics as well as create an Applet that you could plop on a WEB page. Quote QBASIC cannot compile so they will have to distribute it as source False Quote suggesting anybody use QBASIC for any purpose is stupid It's the best way to make a DOS game. The only other option is to use some ancient C compiler like borland and that would suck. Quote Flash would be a good optionQuote I'd go with one of the .NET languages. The problem with these is that your not going to get that kind of classic RPG ambiance; your going to have to emulate it and because of that, these option would not be MY first choice. But if you want it to reach the most people, then yes, you should use flash. The good thing about qbasic though, is it's free and flash is not. Visit this site: http://www.petesqbsite.com/Quote from: Linux711 on November 08, 2010, 12:58:34 PM FalseTrue. Prove otherwise. QBASIC != QuickBasic, QBASIC is free in some older Operating Systems. QuickBasic is not. QBASIC cannot compile the programs you create in it. QuickBasic can. Quote It's the best way to make a DOS game. The only other option is to use some ancient C compiler like borland and that would suck.First, wether QBASIC is the best to make a DOS game is irrelevant. Nowhere in their original post do they make even an implication that they want their game to run or work with DOS. Those implications can only be found in your replies. Even so, AGAIN: QBASIC does NOT COMPILE executables. QuickBASIC does, however it's no newer or more capable then any number of competing products, such as the aforementioned Borland C (or even better, Microsoft C Compiler), which was still being updated long after QB 4.5 (and even QBX) were essentially abandoned by MS. Quote The problem with these is that your not going to get that kind of classic RPG ambiance; your going to have to emulate it and because of that, these option would not be MY first choice. But if you want it to reach the most people, then yes, you should use flash.What the *censored* are you talking about? "classic RPG ambience?" DOS doesn't even HAVE any "classic RPGs" in fact even finding a game that can fit today's definition of an "RPG" is difficult, and those you do find both barely fit that definition and aren't very good in comparison to RPGs that everybody generally associated with the genre, such as those created by Square. In fact, the only thing those DOS RPGs that do exist have in common is terrible control mechanisms, buggy implementations and generally bad execution of the concept. These HARDLY constitute "ambience" you would want to emulate, nor are they intrinsic to the operating platform. Quote The good thing about qbasic though, is it's free and flash is not.FreeBASIC is free too, shares a lot of syntax with QBASIC and QuickBASIC, and actually allows you to compile, which despite any claims to the contrary QBASIC does NOT. FreeBASIC also compiles to both DOS and windows and (I think) Linux, as well. www.freebasic.net Quote Visit this site: www.site.com websites are all terrible in concept and especially in the case of something as antiquated as QBASIC only proves how self-deluded people can get. Personally for 3d games i'd recommend Unity http://unity3d.com. I've only had a play with it myself but if you can get your head around it it is great. There is a free version and a pro version. I've also heard that Dark Basic is good although I have yet to try it. It is commercial software but they seem to have an ad-supported free version for home users. http://www.thegamecreators.com/?m=view_product&id=2000&page=index. The manufacturer also seems to offer other game development software.If you don't want a graphics game and instead prefer a MUD (text based game) then I'd go with building a PHP program on a free webserver like www.justfree.com. I've done this twice, and for the last one GOT funding and now a real server (check out the link in my signature). It's a lot of fun and not too hard, working with PHP/html/css is simple, there's a lot of tutorials, and once it's up it's up and can be played worldwide. That's my two cents anyway ^^ |
|
2456. |
Solve : How to add a multiply & division buttons in the program code???? |
Answer» Sir I runned this program already but without the multiply & division buttons in the program code.And please help me sir!! using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace calculator2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void txtDisplay_TextChanged(object sender, EventArgs e) { } double total1 = 0; double total2 = 0; double answer; private void btnOne_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnOne.Text; } private void btnTwo_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnTwo.Text; } private void btnThree_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnThree.Text; } private void btnFour_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnFour.Text; } private void btnFive_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnFive.Text; } private void btnSix_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnSix.Text; } private void btnSeven_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnSeven.Text; } private void btnEight_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnEight.Text; } private void btnNine_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnNine.Text; } private void btnZero_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnZero.Text; } private void btnClear_Click(object sender, EventArgs e) { txtDisplay.Clear(); } private void btnPlus_Click(object sender, EventArgs e) { total1 = total1 + double.Parse(txtDisplay.Text); txtDisplay.Clear(); plusButtonClicked = true; minusButtonClicked = false; divideButtonClicked = false; multiplyButtonClicked = false; } private void btnEquals_Click(object sender, EventArgs e) { if (plusButtonClicked == true) { total2 = total1 + double.Parse(txtDisplay.Text); } if (multiplyButtonClicked == true) { total2 = total1 * double.Parse(txtDisplay.Text); } else if (minusButtonClicked == true) { total2 = total1 - double.Parse(txtDisplay.Text); } else if (divideButtonClicked == true) { total2 = total1 / double.Parse(txtDisplay.Text); } txtDisplay.Text = total2.ToString(); total1 = 0; } private void btnPoint_Click(object sender, EventArgs e) { txtDisplay.Text = txtDisplay.Text + btnPoint.Text; } bool plusButtonClicked = false; bool minusButtonClicked = false; bool divideButtonClicked = false; bool multiplyButtonClicked = false; private void btnMinus_Click(object sender, EventArgs e) { total1 = total1 + double.Parse(txtDisplay.Text); txtDisplay.Clear(); minusButtonClicked = true; plusButtonClicked = false; divideButtonClicked = false; multiplyButtonClicked = false; } private void btnMultiply_Click(object sender, EventArgs e) { total1 = total1 / double.Parse(txtDisplay.Text); multiplyButtonClicked = true; divideButtonClicked = true; minusButtonClicked = false; plusButtonClicked = false; txtDisplay.Clear(); } private void btnDivide_Click(object sender, EventArgs e) { total1 = total1 / double.Parse(txtDisplay.Text); multiplyButtonClicked = true; divideButtonClicked = true; minusButtonClicked = false; plusButtonClicked = false; txtDisplay.Clear(); } } }Sir please reply me now if my posts here is correct.And please post me a message or example of correct format of code that can be post here. Because I can`t move on in my program code in C sharp because of some errors I did recently here.Okay, If you are the one by deleting my duplicated posts here.That`s good.And I`m very thankful for that sir!! And how it is sir that until now I don`t have RECEIVED a answer for the question I posted here?? Quote from: dave_trodeau2000 on November 12, 2010, 12:19:47 AM And how it is sir that until now I don`t have received a answer for the question I posted here?? You asked this question before, and received a very pertinent answer. Because I`m really don`t know how to delete my duplicated posts here!! I meant, you asked, before, "How is it that until now I haven't received an answer?". You asked this Quote Sir I am waiting from then that my asked question in the date of Oct.04,2010, 4:26A.M.About my C# questions.And hoping to be answered.So now it is no replied messages in my inbox.So how it is Sir like that??and hoping to you sir more power!! The answer is "because nobody posted an answer". There is no guarantee that every question will be answered, and it is foolish to complain if you do not get one. In fact, doing this may make people who know how to help you DECIDE not to post. Sir I`m very thankful for that answer.It`s because I`m really don`t know who is answering my questions here and I think there are working in this site and paid it to assigned for answering a questions here about software programming. And sir can you help me to delete my question here that is my program code in c sharp and a question in above of that code.Because that questions I asked there is very unclear and lack of grammar to be understand by the members here. Quote from: dave_trodeau2000 on November 13, 2010, 08:16:32 AM Sir thank you for this answer.It`s because I`m really don`t know who is answering my questions here and I think there are working in this site and paid it to assigned for answering a questions here about software programming. Nobody is paid here, any answers you might get are from other members like yourself, who may or may not know the answers you need, and are free to answer or not. If people were paid, where did you think the money comes from? Did you pay any money to join or ask questions? Because I`m really new or I am a beginner to asked a questions in forum like this and I have no other forums like this that are the answer is right away or in the same day..And I feel comfortable for this site.. Quote from: dave_trodeau2000 on November 13, 2010, 08:16:32 AM Because that questions I asked there is very unclear and lack of grammar to be understand by the members here. That's somewhat true, but I understood enough to know exactly what the problem was, I believe. Your code contains both of the routines that you SAY you don't have. So I think it follows from that that you have both the button and the code but you cannot "link" them together; that is, you've messed about with them enough that the event has gotten decoupled from the UI element. (this usually happens when you change the name of the procedure). I also know that if you had read the Programmers guide at all, especially regarding the help for the Visual Studio UI, you would know exactly what do do. You can either use the PROPERTIES window to quickly re-link the events back together with their functions or you could even do something really crazy like double-click on the relevant buttons, at which point new Click Event procedures are generated, and use Copy-Paste to move the code from the old decoupled procedure to the new one. The former is quite a lot easier. This is one thing that I personally find rather annoying. nowadays, having a firm grasp of a programming language isn't enough to develop applications in the long-term, since nowadays we have to work with designers. One should make an effort to learn the User-interface and conventions of said environment for the creation of your UI elements, and "connecting" those UI elements with the appropriate code. To be clear, it's not annoying that people that are first learning it have trouble with problems that require UI elements tof the environment that are right in front of their face, it's when people post a question on the forum about it and seemingly stop trying to solve the problem themselves. It's been almost a week since you posted this. You would expect maybe a glance or two at the Visual Studio Programmers guide; specifically, the information on the Properties window. That was why I didn't answer. Both the solution as well as how to find it are neither obscure nor difficult to discover. It's a lack of initiative to blame here, a tendency to "oh, I hit a roadblock- I give up" and then post on a forum, wait a week, and essentially complain that nobody responded. But sir there are no definite answer if there are really experienced to solve any problems about programs in c sharp in this forum,am I right???And maybe myself only or my friend programmer could answer my questions someday about my calcultator program?? Quote from: dave_trodeau2000 on November 13, 2010, 10:54:01 PM And maybe myself only or my friend programmer could answer my questions someday about my calcultator program??I just gave you two answers to your problem.And sir I have a duplicated posts again here.So can I please you sir to delete that again.Please!!! Please! thank you3x sir!!! |
|
2457. |
Solve : Help my C++ doesn't work? |
Answer» Hi i've started learning to program C++ some weeks ago. I have this pdf book that i learn from but i have run into some troubble with a program. The program is as stated here: BCP, I see you cleverly understood what a "cube" function should return... it's always good to help people get top marks for their homework. There is no possible definition for a "cube" function that would accept two parameters that I'm aware of. My first thought was of course to simply make a cube function, but clearly the prototype was important. I had to guess what the function did from the context, and the parameters make the obvious choice of f(x)=x*x*x infeasible. My second guess would be a cube function that for some reason cubes only the nth parameter, but it would be dumb to only cube the 10th parameter and leave everything else untouched, and I certainly hope a book isn't advocating such nonsensical parameter conventions like creating an otherwise bog-standard cube function but making it accept an entire array for the purpose of cubing only a single element. And since no sample output was provided, I just made a standard function that simply used it's parameters in a meaningful way. To my UNDERSTANDING the entire purpose of the exercise was to deal with arrays; and I would certainly hope they would use their definition of the cube() function rather then mine; being that mine was only created due to the lack of the latter and the inability to compile and test without a meaningful definition. Thank you very much it was very helpful Quote from: Vikken on November 14, 2010, 12:34:39 PM Thank you very much it was very helpful You're welcome You might want to double-check my information against a trustworthy source; I did no research for it and it's from my memory so chances are I made a few errors in my recollection of the semantics.Quote from: BC_Programmer on November 14, 2010, 09:14:42 AM actually, it does include the indexing square brackets, but since it was directly in the post, the forum interpreted the [ i ] (without spaces) as an italics tag...oh.! plz excuse me sir, for im new here(actualy that was my first post)...n0w i kn0w..thanks.! @TS you may define the cube function first..for what u have s just a prototype.. |
|
2458. |
Solve : Database? |
Answer» Hey I've GOTTEN this assignment to MAKE a application for a doctor.(Fictional assignment) |
|
2459. |
Solve : Recursion in C++? |
Answer» I am learning programming strategies in c++ and am working on RECURSION. I want to do the following task using recursion: Delete all the nodes in a that match the parameter I pass it, the trick is I want to delete them all but the last occurrence in the linked list. |
|
2460. |
Solve : Help with Objects and Inheritance? |
Answer» I have an object CALLED Comparable as my Base Class. Then I have two derived classes from this class called, CmpInt and CmpString. |
|
2461. |
Solve : gpedit in cmd? |
Answer» is there any command for EDITING gpedit through cmd or bat files PLEASE help |
|
2462. |
Solve : Java Quiz Script Help? |
Answer» Hey guys. |
|
2463. |
Solve : MySQL - add integer to column resulted from SUM function? |
Answer» Hey guys, |
|
2464. |
Solve : c++ user defined types question? |
Answer» I made a vector2D CLASS with a "double magnitude;" data member. I also have some functions that TAKE double as arguments. Is there any way I can put a vector2D object as an argument to these functions INSTEAD of "vector2D.magnitude"? If so, does it work only if magnitude is PUBLIC or does it also work as private?make the structure public in the same namespace as the class but not in the same class. I believe you can simply PLACE the definition immediately before the class definition. |
|
2465. |
Solve : C++ internet...? |
Answer» Does any of you know how to open a internetexplorer WINDOW in C++?SYSTEM ("IEXPLORE"); |
|
2466. |
Solve : hello world colors C++? |
Answer» hi everyone. i just got dev C++. a verry good compiler. |
|
2467. |
Solve : Windows Batch file? |
Answer» Hi all, |
|
2468. |
Solve : [How] to do a reverse engineering on a binary file format ?? |
Answer» HI everyone I want to reverse the .max file format, which is the scene file format, from 3D Studio Max (Autodesk). Unlike the dotxsi format, there is no available information in internet :/ I have HxD, but he's not much usefull for now Please someone help me Thanks in advance 3DS- Max saves files in a proprietary BINARY format; the specification is not public. The actual content of the file is heavily dependent on the plug-in data USED t obuild the scene, thus attempting to parse the file outside 3ds max makes little sense (although some data fragments can be extracted) the file format SUPPORTS certain Windows Shell features line thumbnails, and user info in the header of the file which can be displayed by explorer in a tooltip. The data portion of the file can be optionally compressed using built-in ZIP compression (which means attempts to parse it will need to detect when that compression is used as well as be able to decompress it properly before trying to parse the inner data structures). If you really need access to the data, you could WRITE a MAXScript that runs within 3ds max.Thanks for your answer http://wiki.cgsociety.org/index.php/3ds_Max_File_Formats I already seen that website, but it wasn't that usefull. Finally, I'll use HxD and I'll read 3DS Max SDK. Then I'll be able to do what I need Thanks again and have a nice day ! Bye bye Anonymous |
|
2469. |
Solve : copy file from network on local? |
Answer» please help... you need to create a .vbs file that will run in startup tasks that opens you .bat file where visible = falsehow to full SCRIPT. example : i have 2 computers on the network... computer name one com_1 and other com_2. So on com_1 i have a folder1 in drive d and status sharing, then com_2 want to all copy folder and file on folder1 in drive D at com_1 to drive d on com_2 with the same folder name... How to make script on notepad with extension .bat with echo off the FIRST command. becouse i want to put this file batch command on the start up menu on windows, so that this script file work at the first boot on windows. please... help my problem |
|
2470. |
Solve : c++ only waiting set amount of time for user input? |
Answer» Im writting a program and i want to only wait a set amount of time, like 60 seconds, for the user to input their name. if 60 seconds go by and the user has not entered anything the program will move on. dodgy workaroundit won't work. I'm not even SURE why you think it will. Think about it. the system call will simply take as long as ping does to return. cin's stream input won't even be called until after that OCCURS; and if you imply that a cin is before that small block, that won't work either, because the original problem is that cin never returns until it has input, so cin won't return until after the input has been given, at which point it the program delays for no reason and always displays "timeout". Secondly, Nobody should EVER EVER EVER EVER use the "system" call to implement something like this, or anything, for that matter, except for shelling out another application that is not known until run-time. It's non-portable, and disgusting. If you want to write a batch file, you write a batch file, you don't create a line of "system()" calls and call it C (and certainly not C++). Third: if you aren't going to test your suggestions... what's the point? I don't even need to run that code to say it doesn't work. For the original question, there are two methods that I can think of: create a thread that gets input from the console. You can use WaitForSingleObject() (on windows) to wait on that thread for it to close. Or, you can read data from the STANDARD input character by character in a non-blocking way, this can be put in it's own function: Code: [Select]#include <cstddef> #include <ctime> #include <iostream> #include <conio.h> bool get_input ( char *buffer, std::size_t size, int timeout ) { std::time_t start = std::time ( 0 ); std::size_t n = 0; for ( ; ; ) { if ( n == 0 && std::difftime ( std::time ( 0 ), start ) >= timeout ) return false; if ( kbhit() ) { if ( n == size - 1 ) break; char ch = (int)getche(); if ( ch == '\r' ) { buffer[n++] = '\n'; break; } else buffer[n++] = ch; } } buffer[n] = '\0'; return true; } int main() { char buffer[512] = {0}; if ( !get_input ( buffer, 512, 5 ) ) { std::cout<<"Input timed out\n"; buffer[0] = '\n'; } std::cout<<"input: \""<< buffer <<"\"\n"; } |
|
2471. |
Solve : C++ return char array.? |
Answer» Hay fellas. Been a while. Hay fellas. Been a while. return value should be char[][], If it's an oop project though you should return an array of CString[] pointers. |
|
2472. |
Solve : system ("");? |
Answer» I was TRYING to make a program in c++ that would example, insert a COPY of its self on the desktop (windows 98) so i put this: |
|
2473. |
Solve : c++ methods? |
Answer» There was an example, I can't seem to find now, but maybe someone can help me out. If I return this: (error: 'this' is unavailable for static member functions)it cannot be a static function. You want it to be an instance method. *Fires up VC++* For C++, you have to use pointers, rather then heap-allocated class instances. There are of course differences between references and pointers. Personally I've never used references except where required by an API or as a parameter where I needed to manipulate the parameter's value rather then the class instance it pointed to. in my quick test project, I used a very basic concept that was easy to implement- just a silly little class that wraps addition multiplication and subtraction into a PACKAGE: Code: [Select]#include <iostream> using namespace std; class BasicNumber { public: float Value; BasicNumber(float initvalue) { Value=initvalue; } BasicNumber* Add(float addvalue) { return new BasicNumber(Value+addvalue); } BasicNumber* Subtract(float minusvalue) { return new BasicNumber(Value-minusvalue); } BasicNumber* Multiply(float Multiplyvalue) { return new BasicNumber(Value * Multiplyvalue); } }; int _tmain(int argc, _TCHAR* argv[]) { BasicNumber* xnumber = new BasicNumber(40); BasicNumber* ynumber = xnumber->Add(5); BasicNumber* znumber = ynumber->Multiply(3); cout << xnumber->Value << endl; cout << ynumber->Value << endl; cout << znumber->Value << endl; int tempreturn; cin >> tempreturn; } that segment in the main function, if we were only interested in "znumber" could have been: Code: [Select]BasicNumber* znumber = new BasicNumber(40)->Add(5)->Multiply(3); Basically, each method returns a new instance of the class; this is pretty common practice in the case of immutable objects, for example, it's usually done in the case of strings as well. In your case, you're trying to use static methods, so there will be no "instance" or "reference" to pass anywhere; there is no "this" pointer to return, as you've seen, and you cannot to my understanding pass a static "instance" of a class anywhere. In each algorithm, you are going to need to construct a new "Algorithm" class instance, to hold the result which you then return; if you are manipulating the single character array, then it would need to return the this pointer. Either way, the core methods will probably not be able to be static, if you want to be able to access them as you are suggesting. In fact, the way you have it wouldn't work, anyways; you're trying to return the instance variable "buffer" in a static method (Return); you would have to make the buffer static, in which case it's pointless to have a constructor since there isn't any class instance data to hold (I have no idea if static constructors are supported by C++ or how they might be used); in which case you are basically left with a few functions and some static variables. Basically, the static methods have nothing to work with; the Blowfish() function, for example, is no doubt supposed to encrypt something; but it has nothing to encrypt! the "buffer" field is a instance variable of the class, and the Blowfish() function is a static method and therefore there is no "instance" of the class for it to manipulate. Unless you want to start passing around unrelated structures of function pointers, it might be best to use a instance-method BASED approach. The basic idea of what you want is that each function should return a pointer to a class instance that contains the output data of the called method. Each method of the class would manipulate the data as it is present in that instance and return a new instance with the output data, etc. Similar to the Number example, but obviously a bit more complex; it might look something like this: Code: [Select]Algorithm* Resultalgo = new Algorithm(fileobject)->AES()->BlowFish(); Of course the various AES() and BlowFish() functions could have additional parameters to control encryption. After that, you would end up with a Algorithm Pointer that contains a buffer that is the result of the BlowFish of the AES of the fileobject. No doubt retrievable via a buffer member field, or something- the buffer being the "important" piece of data that each class instance manages. Looks nice. Is it efficient, as in, performance? And when you delete "Algorithm* Resultalgo" after use, it will remove everything related to the class, including the class pointers? Algorithm* Resultalgo = new Algorithm(fileobject)->AES()->BlowFish();Quote from: guss on February 08, 2011, 02:34:21 PM Looks nice. Is it efficient, as in, performance? It depends on how you implement it. If you use immutable classes (like the number example) where the methods basically would take their member "buffer" value and encrypt it, then return a entirely new class that has as it's buffer the result, then you will end up with quite a bit of duplication. In fact, I think it might even have a memory leak; in the BasicNumber* znumber=(new BasicNumber(40))->Add(5)->Multiply(3); case, I couldn't get the two "intermediate" class pointers to deallocate. I'm not sure if they did or not (could be an issue with cout and intermediate value destructors?), I was able to get the resulting znumber to deallocate, however, so I think maybe using pointers results in a memory leak of whatever member variables the class instance contains. In your case, an entire buffer. I was able to get it working with Heap-allocated class instances (so I was dead wrong in stating it couldn't be done that way, thankfully.) Code: [Select]#include <iostream> using namespace std; class BasicNumber { public: float Value; BasicNumber(float initvalue) { Value=initvalue; cout << "BasicNumber constructor, value=" << Value << endl; } ~BasicNumber() { cout << "BasicNumber destructor, value=" << Value << endl; } BasicNumber Add(float addvalue) { return BasicNumber(Value+addvalue); } BasicNumber Subtract(float minusvalue) { return BasicNumber(Value-minusvalue); } BasicNumber Multiply(float Multiplyvalue) { return BasicNumber(Value * Multiplyvalue); } }; void useroutine() { BasicNumber qnumber = BasicNumber(40).Add(5).Multiply(3); cout << qnumber.Value << endl; } int _tmain(int argc, _TCHAR* argv[]) { useroutine(); int tempreturn; cin >> tempreturn; } My original confusion resulted because I thought you needed to use new to create class instances, but you can simply omit the "new" operator and get a heap-allocated instance. (I believe you called them references, and I don't see how that name wouldn't apply). Basically this way is better because all the intermediate class instances have their destructors called. Not really necessary for "BasicNumber" but no doubt your Algorithm class would ideally deallocate it's buffer. Quote And when you delete "Algorithm* Resultalgo" after use, it will remove everything related to the class, including the class pointers?Nope just figured that out above. the intermediate pointers don't look like they get destroyed; deleting (in my example) "znumber" didn't cause any other destructors to run, and those intermediate pointers are essentially "orphaned" since there is no way to get at them. (that I know of). So it would seem that your original idea (with a few minor tweaks) would be the way to go. heap allocation is certainly preferred since the class will have it's destructor called when the variable goes out of scope.Thanks for examples and explanations. This will help a bunch.Maybe you can help me with this one. class 'Generic' is inherited by class 'Sudoku', and then use Printf() to print......this is mostly just for testing on a console application before moving it to a windows app, but hence its a 'Generic' Class.....or is there a better way of doing what I am trying to do? Code: [Select]class Generic { public: class Char { public: Char(); ~Char(); template <typename T> const char* Convert(T variable) { std::stringstream temp; temp << variable; return temp.str().c_str(); } template <typename T> void Printf(T variable) { printf(Convert(variable)); } }; template <typename T> class Transmitter { std::vector<T> v; public: Transmitter(); ~Transmitter(); Transmitter pushback_a(const T d[]) { for(int i=0; i<d.size(); ++i) v.push_back(d); } Transmitter pushback_v(const T &d) { v.push_back(d); } }; }; //-------------------------- Sudoku Game; for(int x = 0; x < 9; ++x) { for(int p = 0; p < 9; ++p) { Game.Char().Printf(Game.board[x][p]); } printf("\n"); } //-------------------------- error: invalid use of 'class Generic::Char'| |
|
2474. |
Solve : Power Shell? |
Answer» I'm very experienced with writing batch files and like using them a lot since they're quick and easy and work just fine for routine jobs as an administrator. |
|
2475. |
Solve : c++ Sudoku? |
Answer» There is almost always 1 NUMBER that has multiples? i am just checking rows, and then later check the columns, and then 3x3. Step by Step. |
|
2476. |
Solve : Kill? |
Answer» I need to make an .exe to kill a task. I am useing Microsoft Visual Studio. I have more then one task that i need it to kill. But i am going to have a file for each task. I dont know how to do it. Can you help me out. That would be the best.Code: [Select]Module Module1 |
|
2477. |
Solve : Programming Basic? |
Answer» Hello everybody, Small Basic: Programming Is FunQuote It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. The above quotation is from Edsger W.Dijkstra, 18 June 1975 More of the context... Quote # PL/I --"the fatal DISEASE"-- belongs more to the problem set than to the solution set.For the rest of the document... http://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html I personally learned COBOL, BASIC and PL/1 early in my programming career. Therefor I am obviously a mental train wreck.Quote It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. You have exposure to BASIC, so are you mentally mutilated?While I am certainly not an expert programmer or anything, I learned Visual Basic 6 first then progressed to C++ and then to Java. I find that Java is the one I prefer for actual programming. But if you want to do some really fun stuff like making a slot machine, or a stop LIGHT that really works or even a simple calculator. Basic is the way to go for beginners you can make the GUI fast and easy and the programs are very simple to learn. Good luck, and have fun. |
|
2478. |
Solve : Please guess me, how can i program counting lines of code?? |
Answer» hello everyone. |
|
2479. |
Solve : VB6 speed question? |
Answer» If I have a STRING array in VB and I need to access a certain element of it many times, is it faster to store it in a separate string variable first? It would be faster to store it in a temp variableOk. I'll do it that way. Quote mysterious element of a global or module-level arrayYes, it is a global array. sl is an array which holds the code and sln is the current line number being read by the interpreter. Quote it might make sense to use a parameterI had it that way originally, but it got annoying to have to always type that extra parameter. |
|
2480. |
Solve : VB Code need help.? |
Answer» Hi I'm kind of a noobie when it comes to programming but anyway I'm learning visual basic in school and I was wondering how to make it so a radiobutton must be checked or else an error message is displayed. ThanksQuote from: JoshM on December 02, 2010, 08:14:31 PM Hi I'm kind of a noobie when it comes to programming but anyway I'm learning visual basic in school and I was wondering how to make it so a radiobutton must be checked or else an error message is displayed. Thanks Radio Buttons can't be checked.If (radSmall.Checked = True) Then costFries = 2.39 I disagree the code property is called "checked" that doesn't mean it's checked. Just like the property for the window TITLE is in the Text property. You don't say "the text I have here in Notepad is "Notepad - UNTITLED"! regarding your PROBLEM you are GOING to have to provide a little more context.http://blackboard.ncc.edu/webct/urw/lc3121856533001.tp3266497323001/RelativeResourceManager/sfsid/3428491390001 Look at #6, it says "The USER must choose a Burger, but does not have to choose Fries and/or a Drink." I'm not sure how you can make it so you dont have to check the fries or drink.Arg sorry, hold on i gotta upload the paper. |
|
2481. |
Solve : DOS - search and count files in XP? |
Answer» Hello, |
|
2482. |
Solve : View Keyboard Keystroke Cache to slow down macro? |
Answer» I am USING JitBit Macro recorder to run keyboard automation routines on one of my computers and was wondering if anyone knew of a way to view the keystroke cache (BUFFER) to see what is in the que for keystrokes to be output to the system. This is not to capture keystrokes as they happen, but to see what are accumulating. |
|
2483. |
Solve : Visual Basic error 50003? |
Answer» My OS is Vista. I'm using a Dell E 521. I have several VB programs that I've TRANSFERRED from my OLD hard DRIVE to the new one, and every time I try to open one of them I get the error"Run time error 50003 unexpected error". ANYONE know what causes this and how to repair it? one of the OCX or DLL files referenced by the project is a different version on the new hard drive (assuming a new install) then the old one. |
|
2484. |
Solve : Java Programming - Does anyone here do 1 on 1 tutoring? (Through MSN)? |
Answer» So I have used Java for about 3 years now and i have tried many TUTORIALS, i know how to write simple commands but i want to know more. I want to get to know the language and learn if there is anything else i can do... I use java for my RuneScape Private Server (Laugh if you must >_<) But I have a very popular server and I want to make it better still... So if you know about RSPS or can tutor me please post back. How good are your Java skills? No to all statements above... Sorry Hi Merlyn, I have just seen this thread while visiting this forum for the first time. I can do one to one tutorial online for the list below: - Polymorphism, Abstraction, Encapsulation, Inheritance etc. - Java Yes - Multithreading - Java: In the near future - Database programs (insert, update, delete) - Java: In the near future - Space Invaders - Not yet Let me know if these are of interest to you. The OP did not say where he LIVED. Or what he circumstances are. If after studding something for three years and not make progress, one would be inclined to consider is proprietors. Reading skill is very important in Information Technology. Still, a tutor nan help in some cases. Has the OP considered the courses given at a local college? And there are many on-lines courses available, for a fee. Microsoft is the dominant innovator in the Desktop Software Market Place. They no longer support java programming. They advocate C++ as the alternative for Windows programming. They have forums and a large database to help you learn programming for a Windows Desktop system. Just Google Microsoft C++ tutorials Don't get me wrong. Thee is and will continue to be a place for java. But the GENERAL consensus at this time is to learn C++ as presented by Microsoft it you want to do programming in Windows. As for doing a Web Site in java. Sure. Easy. You just get somebody else to do it. If you have a popular site, some of your regulars might volunteer to do it for you. If you are a good administrator and business manager, let somebody else do the code. |
|
2485. |
Solve : please help trying to figure out? |
Answer» doing crammers rule |
|
2486. |
Solve : QuickBASIC 4.5 .BAS -> .OBJ? |
Answer» I need a way to convert an ASCII .BAS file to a .OBJ independent of the QuickBASIC environment. I am trying to make a program that can compile QuickBASIC code. After I get an OBJ, I can get an EXE from there. Is this possible? Please explain. I am trying to compile a program from a command-line without loading QB4.5. FreeBASIC is a free and open-source BASIC compiler. It is compatible to a large extent with MS-QuickBASIC (QBASIC), but has additional features such as pointers, unsigned data types and inline-assembly.I am sure somebody planning to write a compiler will have heard of Google. Quote from: Salmon Trout on December 05, 2010, 01:22:16 PM I am sure somebody planning to write a compiler will have heard of Google.Maybe Still, others who read this may benefit. Also, if somebody has a small program in QB code, there is little point in running it through a compiler. The interpreter QBASIC.EXE still works fine at the command line and will run many of the old programs. The advantage of FreeBasic is that it is open source.Quote from: Geek-9pm on December 05, 2010, 05:47:05 PM Maybe Of course, QBASIC is not provided for the last several versions of windows. I believe the last version to include it was Windows ME (it might be in XP, but it's definitely not in Vista) Quote The advantage of FreeBasic is that it is open source. FreeBASIC is probably better because it runs on more then 1 platform. QBASIC/QB/QBX only run on 16-bit MS-DOS compatible systems. Windows x64 systems need not apply. FreeBASIC provides DOS, Linux, Win32, and Mac compatible executables that can compile and run BASIC programs on a variety of platforms, not just Real-Mode DOS. Quote from: Fleexy on December 05, 2010, 12:11:46 PM I need a way to convert an ASCII .BAS file to a .OBJ independent of the QuickBASIC environment. I am trying to make a program that can compile QuickBASIC code. After I get an OBJ, I can get an EXE from there. Is this possible? Please explain. I am trying to compile a program from a command-line without loading QB4.5. You can use the BASIC Compiler, BC.EXE. http://support.microsoft.com/kb/43090The main disadvantages of QBASIC were: 1. It was very addictive one you got the hang of it. 2. The label on the F5 key would were out. The following video was NOT made by BC. But it could have been. How I became a QBASIC Nerd Video. Quote from: Geek-9pm on December 05, 2010, 05:47:05 PM The interpreter QBASIC.EXE still works fine at the command line Not on any 64 bit OS Quote from: Salmon Trout on December 06, 2010, 11:25:33 AM Not on any 64 bit OSYes. QBASIC is a 16 bit program. But have you tried o any 64 bit OS? By 'Any' do you mean 'All' or almost all? Have you tried it on all 64 bit OS? Did you try it in a DOS compatibility mode? Some see this as a bad thing in Windows 7 64 bit. If you want to run ole 16 bit programs you have for forfeit running 64 bit programs. Or do you? Here is just one of the critics. http://windows7critics.blogspot.com/2009/01/16-bit-applications-do-not-work.html He says: Quote ...VirtualPC to run 16-bit OSes...Quote from: Geek-9pm on December 06, 2010, 03:34:04 PM Yes. Let's see, WinXP x64, nope. WinXP 74-bit edition, nope. Windows Vista x64? Nope. Windows 7 x64? Nope. Linux Mint AMD64? Nope. I think that pretty much covers it. Quote Did you try it in a DOS compatibility mode?There hasn't been a "DOS compatibility mode" since windows 98. The compatibility mode options are for 32-bit windows programs. Quote Some see this as a bad thing in Windows 7 64 bit. If you want to run ole 16 bit programs you have for forfeit running 64 bit programs.I don't. I cannot think of a single 16-bit program that still has very much relevance today. QBASIC is not addictive nor "fun" it's annoying and archaic compared to what you can get for free. He says: [/quote] ...VirtualPC to run 16-bit OSes... [/quote] Quote The interpreter QBASIC.EXE still works fine at the command lineWhen did virtual PC become a command line? And seriously? I find it hard to believe that anybody would want to actually seriously want to use QuickBasic, and even less for QBASIC. FreeBASIC is, A:) free and B:) runs on win32, Linux, as well as DOS and compiles to executables for each of those platforms. to recommend a PIECE of abandonware instead is bone-headed. I find the blog post you linked to rather interesting: Quote To-do list for Microsoft For 64-bit Windows 7: Both of these are stupid. How about instead of microsoft bending over backwards and maintaining backwards compatibility like they've been doing for the last 25 years (and people have complained about exactly this for at least 10) people actually go out and get updated flipping software! if you want to use Edlin, you're a masochistic idiot, and you may as well just run QDOS. If you want to use EDIT you may as well just run a DOS system, Obviously you have no need for the built in damned Text editor that COMES with windows... of course not, you'd much rather prefer the EDIT utility, which has absolutely no advantage over Notepad. I have no problem with old software- I use EDIT all the time on the DOS systems I own- what I have a problem with is people who insist on running the latest hardware and still think that Microsoft should go out of their way to make sure they can still use Word for DOS on their x64 machine running Windows 7 or run word for windows 2.0. It's utter nonsense. If you want to run "Word for DOS" run DOS. if you want to run Word for Windows 2.0, you run windows 3.1. If you're too cheap to buy the later version of the software that does work, why the *censored* should microsoft bother to make sure your needs are met? there is no "contract" implicit or explicit that says that Microsoft, or any software vendor, is going to change the way they engineer their later Operating systems because you paid them 40 dollars for a piece of software in 1992. Quote from: BC_Programmer on December 06, 2010, 04:00:21 PM Let's see, WinXP x64, nope. WinXP 74-bit edition, nope.Thanks for your research. Actually, it was $80 and it turned out to b e pirate version of Office XP. I am still mad at MS for releasing pirate software. But it still runs good and at least it was not 16 bit. As for QBASIC, it still runs on my Windows 2000, which is a 32 bit. By the time I get a 64 bit system, MS will be out of business. They will be bought by Wallchart. Or maybe McDonald's. Quote from: Geek-9pm on December 06, 2010, 04:54:51 PM As for QBASIC, it still runs on my Windows 2000, which is a 32 bit. By the time I get a 64 bit system, MS will be out of business. They will be bought by Wallchart. Or maybe McDonald's. Actually, you raise something interesting I've noticed over the years in various Video publications regarding computers. All sorts of "experts" and company analysts, and even people from other companies, predict various negative things happening to microsoft. For example, A Sun Microsystem employee and premier architect of the JavaStation (in 1998) predicted that MS would be "made obsolete" since net-only computers (like the Javastation, Acorn Network computer, etc) were the future. The thing is, while they were all hedging their bets on what was "going" to happen (they had no doubt that it was going to happen, for some reason). watching the video, it's impossible not to smile when they say that MS has no business sense since they aren't jumping into the net-station thing like Sun and Apple and so forth. What I found most interesting, is that of all the people they interviewed in that video, the only person who QUITE literally said "well, you can't predict the future, so you have to work with the present" was in fact Bill Gates. The Sun representative was adamant that the Javastation was going to change the world; Bill made a point that while you have to keep innovating in order to prevent from being buried (like, say, Digital Research, MITS, and so forth) you cannot prematurely jump at new innovations because you can never predict how they will turn out. It doesn't take a genius to see how clever that analysis was, the only person who seemed able to "predict" the future was the one person who said it was impossible. everybody else was trapped up in the hype of Java and "network computing" and had already left the present day; they "knew" what the future was but never considered that there would have to be a transition from what we had then to that future. Needless to say their vision of the future never came to fruition, and even sounds ridiculous today. Quote from: Geek-9pm on December 06, 2010, 04:54:51 PM Actually, it was $80 and it turned out to b e pirate version of Office XP. I am still mad at MS for releasing pirate software. But it still runs good and at least it was not 16 bit. From the context it should have been CLEAR I was talking about Word for DOS and Word For Windows 2.0. Both 16-bit programs. Not Office XP. MS doesn't release pirate software. That's a rather stupid thing to say. Quote MS doesn't release pirate software. That's a rather stupid thing to say.Pirates of Silicon Valley-Microsoft steals from Apple http://www.youtube.com/watch?v=im589uTchKsQuote from: Geek-9pm on December 06, 2010, 05:58:53 PM Pirates of Silicon Valley-Microsoft steals from Apple I've seen that movie. Such nonsense. |
|
2487. |
Solve : C++ read from file into a 2d vector? |
Answer» Hi all, Not much help probably, but when playing with graphic rendering for C++ I usually work with bit maps, which are easier to manage than reading in ascii from text file and vector rendering it. What type of application is this going to be a user input/output type of application or a game? he didn't even hint at graphics of any kind... |
|
2488. |
Solve : bat file to commpress folder? |
Answer» dear all |
|
2489. |
Solve : vbscript code need help..? |
Answer» I have to create a random number from 1-100 using vbscript and Wscript.Echo intNumberi don't understand this code, is this code means to write the random number? thanks. Quote i don't understand this code, is this code means to write the random number? Yes. Did you run the code? If you need a different type of output, you need to be more specific. it worked actually. thanks a lot! |
|
2490. |
Solve : vbscript sorting? |
Answer» how to sort an arrays without using bubble sort? |
|
2491. |
Solve : SetCursorPos Help? |
Answer» HI im a little new to VBScripting, i wanted to move the mouse so this is what i USED. "SetCursorPos (100,400)" That is all i typed. I got the error "Cannot use parentheses when CALLING a Sub". What does this mean, how do i fix it, and what is a Sub? Thankyou!Your use of SetCursorPos is ambiguous. Are you referring to the Windows API SetCursorPos function or do you just happen to have a subroutine in your script named SetCursorPos? If it's the former, VBScript cannot access the Windows API directly. You will need to create a wrapper for the API function, then use CreateObject function in your script to INSTANTIATE the object. If it's the latter, simply REMOVE the quotes and the parenthesis: SetCursorPos 100,400 If need more assistance, get back to us. Good luck. My vbscript addition called wshshell can do this. It can also simulate mouse clicks and make windows. You can download it here: http://www.mediafire.com/?j1vim4bf5hb9qxm After downloading unzip using 7-zip. Then run the install.bat found in the extracted folder. Now you can use SetMousePos like this: Code: [Select]Option Explicit Dim wsh Set wsh = CreateObject("wshshell.io") wsh.SetMousePos 100, 400 wsh.LeftClick etc... Set wsh = Nothing EDIT: Realize that it may be SetMousePos instead of SetCursorPos in my program. Can't remember right now, and can't check because i'm on a mac |
|
2492. |
Solve : Help with Java? |
Answer» So I've got an assignment to do but I don't quite get it, I'm supposed to make a program let's say for a company with x number of employees, what the program does is that it stores the name, age and salary of each user by using both arrays and a different class (Object oriented). The thing is I have no idea how to combine arrays with a different class, I made something but it doesn't use another class so I won't get a grade, if anyone can help me use this with another class I'll be grateful /*sounds like the intent is to get you to use an array of instances of a class, like say EmployeeInfo[], and then the class has the Name, Salary, and other employee based information. It's also rather interesting that the whole "employee table" example is still being used. That's in my Visual Basic version 2 programmers guide aaaah :p , I came up with this but I don't know what's wrong and I'm desperate Employee class Quote /* Main Quote /*no, you have teh arrays in the class instances, what you want is a MEMBER on each instance, and array of those instances, such as: Code: [Select] public class Employee { public double salary; public String name; public int age; public Employee(String pname, int page,double psalary) { salary=psalary; name=pname; age=page; } } and then later in the code (the other SECTION) you would create an employee simply like so: Employee mEmployee = new Employee("George",47,43000); and then add that instance to an array. |
|
2493. |
Solve : Need help creating a bat file? |
Answer» Hi Alternatively a piece of php code that will call a HTML file with the same filename as the php file. So say the php file is named 208.php is there code i can insert which would look for a HTML file with the same name (208.html) Code: [Select]<?php include(basename(__FILE__)."html"); ?> Thanks again, for reply. I pasted your code into my php file but get this error when i use Wampserver to run the script. Warning: include(208.phphtml) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\ds\current\details\208.php on line 42 Warning: include() [function.include]: Failed opening '208.phphtml' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\ds\current\details\208.php on line 42 As you can see its now trying to call 208.phphtml how do i get it to drop the php in the extension?sorry, my mistake, turns out that the basename function doesn't return the basename. haha. Code: [Select]include(basename(__FILE__,".php") . ".html");You are a star that works a treat, saved me so much manual editing! I owe you a drink |
|
2494. |
Solve : How to authenticate the user using the PC Mac address? |
Answer» Is it possible to only allow USERS to access my website with their PC Mac Address authentication? One's the user access my website, the mac address will be first check if it is a valid mac address before it will completely view my website. Or is it ideal to only use CERTIFICATE authentication? Please ADVISE if what's more secure? or just by using https instead of http? Thanks |
|
2495. |
Solve : Send Packet - VB .NET 2005? |
Answer» Would somebody please explain to me how to connect to another computer and send/receive packets using VB .NET 2005? I have searched the Help and understand none of it. Help would be much appreciated. Would somebody please explain to me how to connect to another computer and send/receive packets using VB .NET 2005? I have searched the Help and understand none of it. Help would be much appreciated. Network communications via the .NET Framework can be done using several classes, including the core Socket class; HOWEVER, most network communications required will use one of several classes that use the socket class; for example, TcpClient and TcpListener. I have never used VB.NET, my version is 2008, and it seems Resharper doesn't like it so intellisense is busted all around with it; but, my small IRC engine that I wrote in C# does use the various TCP classes to perform TCP/IP transfers. Basically, unless you have some specific reason to want control over the packet level, you shouldn't. And very few applications require control over the packet level so tcpClient/Listener are probably a better choice. The RELEVANT part of my "connection" routine converted to VB.NET would probably be something like this, with the REDUNDANT bits that only involve IRC removed: Code: [Select]private Sub Connect(phostname as String,pPort as Integer) clientconnection = NEW TcpClient(phostname,pPort) netstream = clientconnection.GetStream() netreader = new StreamReader(netstream,Encoding.ASCII) netwriter = new StreamWriter(netstream,Encoding.ASCII) End Sub clientconnection,netstream,netreader, and netwriter are class (or form-level, if you prefer) variables: Code: [Select]Private clientconnection as TcpClient Private netstream as NetworkStream Private netreader as StreamReader Private netwriter as StreamWriter Basically, what you end up doing is treating that Tcp Connection as a single "stream; you read from it and write from it just like you would from a file-based stream. In my program, in order to follow the IRC protocol, whenever I read "PING" from the stream, I need to respond with a "PONG", this is done simply by writing it to netwriter. If you aren't familiar with File I/O, you should take some time to familiarize yourself with it; Network I/O uses largely the same classes, the only difference is those classes are dealing with NetworkStream, rather then a FileStream. If you are familar with File I/O then you're already familiar with everything you need to use tcpClient. If you want to Listen, you use TcpListener, listen to the local Port: Code: [Select]Dim localAddr As IPAddress = IPAddress.Parse("127.0.0.1") Dim server As New TcpListener(localAddr, port) server.Start() At that point you would wait (either with a loop, ideally on a separate thread) until something connects to your listener, at which point you can use the AcceptTcpClient() to get back a TcpClient object, just like the one you create to connect to something; then you can acquire the streams in the same way and start communication with whatever connected as needed. Quote from: Geek-9pm on December 20, 2010, 11:24:53 AM VB .NET has some revisions. Why limit yourself to a five year old product?While in concept I would agree, there are several things to consider: 1. using Version 2008 would require .NET 3.5; using Version 2010 would require .NET 4.0. and while you can create .NET 2.0 (2005) applications with those, it doesn't really add much when you do so. 2. Unless you are planning on using LINQ and WPF, or you need specific functionality that the new version provides, there is absolutely no reason to use the newer frameworks nor is there any reason to code against those newer frameworks; code should be written to the lowest common denominator whenever possible to run on the most machines. 3. They asked how to do something on Visual Basic 2005. you turn around and basically ask them why they are using Visual Basic 2005 when there are newer versions. It doesn't even come close to answering their question nor do you provide any insight into how the version they are using is even remotely relevant to the task they want to perform. Then you provide a link to some long-dead RS232 terminal communication protocol. Quote 3. They asked how to do something on Visual Basic 2005. you turn around and basically ask them why they are using Visual Basic 2005 when there are newer versions. It doesn't even come close to answering their question nor do you provide any insight into how the version they are using is even remotely relevant to the task they want to perform. Then you provide a link to some long-dead RS232 terminal communication protocol. FOR Foot in Mouth 1 & 2 WhineLine <My Bad> NEXT Foot |
|
2496. |
Solve : run Batch-file export in excel (its for a Movie database) Helpme? |
Answer» Hi a Filter should display Unseen, unKnown, Seen in different colors LOL The NT sort command does not support multiple sort keys. Use Excel instead. You can color code the data by grouping in Excel. Quote If I Run an batch file daily is that bad for the computer? No. Computer are very good at repetition. Put it to work and make your own LIFE easier. Quote Does batch files also work in Windows 7. I still got XP Later upgrade to Windows 7 Batch files still run in Win7 and probably beyond for the foreseeable future. Win7 also has other tools such as VBSCRIPT (installed on Win98 forward) and Powershell (installed on Win7; add-on back to Win2000) Good luck. |
|
2497. |
Solve : javac Command Prompt Issue? |
Answer» Hello all, The folder that contains javac.exe should be in your PATH system variable if you just want to type javac xxx.java. If it is not on your PATH and it seems like yours is not, you have to type the full path to javac.exe. Do you know which folder it is installed into? Did you follow the install instructions carefully? have you restarted the computer since installing Java? Hey Salmon, thanks for your response. I found the javac.exe file in "C:\Program Files\Java\jdk1.6.0_23\bin" (I had the JDK install in its suggested location). I did find the "java.exe", "javaw.exe", and "javaws.exe" in "C:\WINDOWS\system32" folder (that would be the Path folder right?; I don't know hardly anything about Paths) in addition to being in "C:\Program Files\Java\jdk1.6.0_23\bin" folder. When I did the installation (I installed it yesterday), I followed the instructions provided by the installer dialogue box, but I MIGHT have over looked special instructions if they were on Oracle's website. As far as a restart, I did not restart the computer right after the installation completed but instead tried to get the Hello World program to run (obviously unsuccessfully). Since yesterday and today however, the computer has been restarted. Would you recommend uninstalling the JDK and reinstalling it or is there a simpler fix to this issue?Did you uninstall any PREVIOUS versions of Java (JRE for example) before you installed the JDK? |
|
2498. |
Solve : vb express append to file? |
Answer» in VISUAL basic express how would i append a string called list to a text file call recipes.txt in the current directoryyou should always check MSDN first (or google). Use the append mode when opening the file for writingno the problem is i cant write to the file at all i should have been more specificQuote from: mat123 on December 24, 2010, 06:33:30 PM no the problem is i cant write to the file at all i should have been more specificand why are you not being specific about why you can't write to file , when you know you should? What error messages? did you open you file properly? Without your code, there's no way to know what went wrong isn't it?Code: [Select] Dim path As String = My.Computer.FileSystem.CurrentDirectory() Debug.Write(path) Dim sw As System.IO.StreamWriter Dim Loc = path + "recipes.txt" sw = My.Computer.FileSystem.OpenTextFileWriter(Loc, True code] then a sw.writeline(list)tips: -Stay AWAY from the My Namespace stuff. IMO it's a pretty big hack; also, it doesn't exist in any other .NET language, so in a way it's SOMEWHAT "non-standard". - Use Path.Combine() to combine paths. Example: Code: [Select] Dim destfile as String = Path.Combine(Environment.CurrentDirectory,"recipes.txt") Dim fstream As FileStream = new FileStream(destfile,FileMode.Append) dim twriter as StreamWriter = new StreamWriter(fstream) dim list as String="list" twriter.WriteLine(list) twriter.Close() I haven't a clue what your list variable was SUPPOSED to be. i still does not write to the file there is no error thoughWhy don't you check out MSDN (which i have already told you in my first post ) and see what they say. EXECUTE the example code provided, and see if you can write to file.i finally got it work but how do it get it to be a exe the publish option makes a setup file i just want a stand alone exeuse Build->Build Solution. (Assuming the express versions are similar in menu structure to Professional) thank you both of you for your help. |
|
2499. |
Solve : Batch Script To Log Only The Names Of Files In a Backup Job? |
Answer» Please I need a batch script that will log only the names of files in a backup job. I'm using the batch script below but the log FILE includes the path of the source files as well, how do I remove the path from the log? Please note that I did not pay a panny to experts-exchange.com the code above was on their website just scroll down to the bottom of the page. The solution is blurred out until you login/register, the latter of which requires GIVING credit card details.When I got the code it wasn't blurred out, good job this was so as I need the code for a project I was working on at the time. Quote from: BC_Programmer on December 26, 2010, 11:00:12 PM The solution is blurred out until you login/register, the latter of which requires giving credit card details. It's not blurred out in Google's cache... am I allowed to say that here? |
|
2500. |
Solve : Need help with tictactoe network game? |
Answer» So my project is due tomorrow and I'm not sure (Actually I have no idea) what's wrong with it, it's all working good except somehow the if conditions are wrong because it NEVER sets text in the jlabel to say win, here's the code Code: [Select]if(jButton1.getText().equals(jButton2.getText()) && jButton3.getText().equals(jButton1.getText())&&jButton1.getText().equals("o")) { The last condition is checking wether it's equal to "o" but you have been setting them to "O" (capitalized). |
|