

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.
351. |
Solve : music license override? |
Answer» i need HELP overriding the license agreement on some music i am trying to transfer from one laptop to another via FLASH drive. both LAPTOPS are mine. the music was downloaded from the internet. but my OLD laptop was currupted and the license agreements were lost.But wouldn't that technically be illegal...? |
|
352. |
Solve : Runing a batch file without the command window? |
Answer» Can some ONE tell me how to run a batch file wthout opening the command window. |
|
353. |
Solve : Batch file problems, concerning files? |
Answer» Okay .. Here it is: |
|
354. |
Solve : How can I install a scheduled task?? |
Answer» Greetings |
|
355. |
Solve : new to batch files? |
Answer» ok i am learning to make batch files and i was bored and i desided to see if i could make a batch file to run my aim,msn messenger and yahoo messenger all at the same time, but for some reason the yahoo messenger will not work, i am running windows xp pro and this is the code: |
|
356. |
Solve : Can 2 threads run simultaneously in HT processor?? |
Answer» HAI, Can anyone explain the following? Can two threads run simultaneously in Intel PENTIUM 4 Processor with Hyper Threading, BASE PC (Windows 2000 OS) without timeslicing???I'm not sure what PIV means, but this site will explain all. Hyperthreading Good reading on a cold NIGHT. |
|
357. |
Solve : Testing Strategy, Test Cases? |
Answer» Hi, |
|
358. |
Solve : Help fine tuning batch file? |
Answer» im having TROUBLE setting my default printer depending on the IP address of my machines. Below is the code i have so far and i was wondering if anyone new where i was GOING WRONG. |
|
359. |
Solve : Transforming image to text? |
Answer» Hi, I'm trying to make a program in VISUAL Basic 6.0 that will be able to take a picture and break it into text. I also want it to be as SMALL a file as possible so I'm trying to convert the IMAGE into GREYSCALE with 10 shades of light (white to black) and each pixel is represented by a number 0-9. If anybody has any IDEA how to do this it'll be a huge help. Thanks |
|
360. |
Solve : Text size some how changes on users computers? |
Answer» Hello Everyone, |
|
361. |
Solve : DOS Batch File text processing query? |
Answer» Can anyone tell me how to extract some information contained in a text file called dircount.txt and place it in an environment variable ? I want to be able to extract the number 5 from the text file contents as shown below. I want to do this using DOS batch files. |
|
362. |
Solve : Send file as an attachment from the command line? |
Answer» Is there any way to send an email attachment from the command line? I have tried Blat and have used it on our LAN but it dies during dial up connection for our remote clients. There must be a way to send an email attachment from the command line by using vbscript or jscript. Any HELP with this would be greatly appreciated.Code: [Select] |
|
363. |
Solve : Making a game..sorta? |
Answer» I had a few questions about Virtual Basic and was WONDERING if anyone could help.... To begin with I have two forms..One called children and the other called game.Game has three option buttons on it and so does game. both of them also have a label.I also have a command box.The label would be where I put the question and the option buttons where I put the answers.the command box is called answer...I want to make it so when I click the answer Paris it will log my answer and open the other form children..I TRIED doing it but I didn't know the extension for the option buttons,to link a form, or a label...I do not understand how to do this..PLEASE help..thank YouIn the click event for the Paris option, you could Unload Me and Children.Show. |
|
364. |
Solve : languages? |
Answer» How would I go about CREATING my own language/compiler?What do you know so far? |
|
365. |
Solve : Logging into Windows XP Home? |
Answer» I had a few questions about Visual Basic and was wondering if anyone could help....to begin with I made a program that asks for a user/password...It had no toolbar so you cant close it..I needed help to make it so that you cant do anything ( WINDOWS KEY or Ctrl+Alt+Del) To get out of it...I WANTED to make this my Screen when I log on to windows replacing the other one..I've seen many people do this but don't know how.I heard you have to replace some file or something...I also needed the program to be like this: If you log on with the main(admin) pass then you have full rights while if you log on with a temp user and pass you only have 10 MINUTES to do what you want (internet acces restriced) before it shuts down..So I NEED help with the timer in VB and also how to make a Temp user and pass...I have a windows XP home...Any help will be appreciated...Thanks |
|
366. |
Solve : How to make an object move a direction? |
Answer» I'm working in Visual Basic 6.0 and I'm trying to figure out how to MOVE an object a distance based on a number of degrees (Like moving an object 1 unit to the left, except left=80Degrees and I want it to be able to calculate all 360 degrees.) |
|
367. |
Solve : .exe file? |
Answer» ::) I NEED help viewing a EXE file as text? This file is a utility file on a Domain? Anybody know how to send the results as text for viewing?What do you mean??? |
|
368. |
Solve : visual basic combobox? |
Answer» HELP please i don't KNOW how to use a combobox in VISUAL basic 2005 EXPRESS edition beta |
|
369. |
Solve : IF statement in Batch File Help? |
Answer» Here is the command I'm trying to make work.... |
|
370. |
Solve : Log in Program...? |
Answer» I had a few questions about Visual Basic and was wondering if anyone could help....to begin with I made a program that asks for a user/password...It had no toolbar so you cant close it..I needed help to make it so that you cant do anything ( WINDOWS key or Ctrl+Alt+Del) To get out of it...I wanted to make this my SCREEN when I log on to windows replacing the other one..I've seen many PEOPLE do this but don't know how.I heard you have to replace some file or something...I ALSO needed the program to be like this: If you log on with the main(admin) pass then you have full rights while if you log on with a temp user and pass you only have 10 minutes to do what you want (internet acces restriced) before it shuts down..So I need help with the TIMER in VB and also how to make a Temp user and pass...I have a windows XP HOME...Any help will be appreciated...Thanks |
|
371. |
Solve : working with Radiobutton in JBuilder2005? |
Answer» Hi everyone. I am USING JBuilder 2005 on windows XP Professional. I shall be very thankfull to you, if you can let me know how to work with radiobutton while using JBuilder. I have created two radio buttons. Add them in a buttongroup and when I RUN my program they behaves exactly like radio buttons. Next, how to add code to them? I do hope that you have GOT my point. |
|
372. |
Solve : Detecting System Shutdown? |
Answer» Is there anyway in visual basic I can detect if the my PC is shutting down,is there any code I can use?I'd like my vb application to detect my computer's state,if it is shuting down,please I really need a very QUICK help,thanks for the time....Trying monitoring the SYSTEM event log. When event #1074 is posted, you'll know shutdown has begun. |
|
373. |
Solve : Delete multiple files? |
Answer» Can anyone help me?? What I am trying to do is Wright a Vbscript that will loop through a LIST of files and delete them. Does any one have any suggestion? I was trying to use loop but I can’t get it to work.Where is this list of files coming from? If an external source, you can read the file and delete the files as you GO. If coming from the same directory you can get a collection of file names and loop thru the collection. |
|
374. |
Solve : How to automatically overwrite??? |
Answer» This is the first BATCH file I have written. It is a simple xcopy routine, moving two files from ONE location to another over night as part of a back-up. |
|
375. |
Solve : For geek-9pm :D? |
Answer» FORTRAN IDE BUILT on ECLIPSE! |
|
376. |
Solve : Linking issues while migrating code from SUN CC 4.3 to SUN CC 5.8? |
Answer» Hello, |
|
377. |
Solve : Password Validation? |
Answer» So I have an MS Access db application that I'm working on. The part that i need help with, is validating password strings for the new user function. Simply, the add user form passes all the info to the SQL db. I ran into the problem of password strings containing symbols not wanting to work at all, though it WOULD pass to the db just fine, wouldn't allow logging in with them. Also, if the initial character was a number, it didn't like that either. As long as these two conditions weren't there, then it works perfectly. Creates the user and their credentials are READY for use in <30s. But if it starts with numbers or contains symbols - merp. no work. |
|
378. |
Solve : Game Coding Starter? |
Answer» I was wondering if anybody can link me to like a started pack for GAME coding. Like all the software I need and recommend a language. I already know a bit of java, but I heard c# is really good. Any help is appreciated THANKS!You can keep you Java skills. Yes,Java s having some times right now. But it is a security issue, not about the power of Java. |
|
379. |
Solve : Please HELP with '.xml' file extension!? |
Answer» Hi, first off, I simply wanted to THANK all of you for taking the time to look into this minor problem. A while BACK, I did some meandering on my laptop and aimlessly clicked through different programs, checking, un-checking, deleting, and what not. Now, I recently purchased Sony's ACID Music Studio 9.0, every time I MAKE an attempt to double-click the '.xml' files (which I believe are also the music riffs) I get the following: As of 2009, hundreds of document formats using XML syntax have been developed,[7] including RSS, Atom, SOAP, and XHTML. XML-based formats have become the default for many office-productivity tools, including Microsoft Office (Office Open XML), OpenOffice.org and LibreOffice (OpenDocument), and Apple's IWORK. XML has also been employed as the base language for communication protocols, such as XMPP.From the above you can see it is not tied to music. It is a common code used to 'glue' pats of internal stuff that makes sense only to advanced software people. Do not alter the XML things. For more information, rared the documentation of Sony's ACID Music Studio 9.0, http://www.sonycreativesoftware.com/download/manuals/acidfamily Hope this helps. Please come back an d let all know if you like ACID Music Studio. Geek-9pm, I appreciate your reply! I'll take a look into it! And, I'll definitely let you all know how well ACID Music Studio is! Be safe! |
|
380. |
Solve : help me..why my program get"expected class delegate enum interface or struct"??? |
Answer» USING System; using System.Collections.Generic; using System.Runtime.Serialization.Formatters .Binary; //namespace to use Serialization class Record { private string name; public string Name { get { return name; } SET { name = value; } } private double homeNumber; public double HomeNumber { get { return homeNumber; } set { homeNumber = value; } } private double mobNumber; public double MobNumber { get { return mobNumber; } set { mobNumber = value; } } private string address; public string Address { get { return address; } set { address = value; } } // Default Constructor public Record() { this.name = string.Empty; this.homeNumber = 0000; this.MobNumber = 0000; this.address = "Fake"; } // Parameterized Constructor public Record(string n, double hNum, double mobNum, string add) { this.name = n; this.homeNumber = hNum; this.mobNumber = mobNum; this.address = add; } public void print() { System.Console.WriteLine("The Name Is : " + this.name); System.Console.WriteLine(" Home Phone No. Is : " + this.homeNumber); System.Console.WriteLine(" Mobile Phone No. Is : " + this.mobNumber); System.Console.WriteLine(" Address Is : " + this.address); } } // Add a new Record first to ArrayList(recordList) and then in file public void addNewRecord() { recordList = new ArrayList(); records = new Record(); // Here Adding Record to ArrayList recordList.Add(new Record("osama", 36887676, 3333003212,"Lahore")); recordList.Add(new Record("saad", 4234234, 33330065656, "Ali Park")); recordList.Add(new Record("bilal", 2123456, 0456123232, "Multan")); recordList.Add(new Record("maryam", 1312312, 33330032121,"Karachi")); FILESTREAM fs = new FileStream("data.txt", FileMode.Create, FileAccess.Write); BinaryFormatter bf = new BinaryFormatter(); } // Loads the all reocrds from file and add to ArrayList(recordList) public void loadRecord() { recordList = new ArrayList(); FileStream fs = new FileStream("data.txt", FileMode.Open, FileAccess.Read); BinaryFormatter bf = new BinaryFormatter(); try { while (fs.CanRead)//Reading the FileStream { Record R = (Record)bf.Deserialize(fs);//De-Serialize the each object recordList.Add(r); //And Add to ArrayList r.print(); //Printing the each record from the file to console } } catch (Exception e) {} fs.Close(); } // Saving the record to file. public void saveRecord() { FileStream fs = new FileStream("data.txt", FileMode.Create, FileAccess.Write); BinaryFormatter bf = new BinaryFormatter(); for (int i = 0; i < recordList.Count; i++) { record = (Record)recordList; bf.Serialize(fs, record); fs.Flush(); } fs.Close(); } public void enterInPhoneDirectory() { record = new Record(); loadRecord(); Console.WriteLine("Enter Your Home Number/ Mobile Number : "); double number = double.Parse(Console.ReadLine()); // User to enter his/her Home/mobile no. for (int j = 0; j < recordList.Count; j++) { record = (Record)recordList[j]; if (record.HomeNumber == number || record.MobNumber == number) { Console.WriteLine("Welcome , " + record.Name.ToUpper()); record.print(); Console.WriteLine("Press 1 to Change Home Number"); Console.WriteLine("Press 2 to Change Mobile Number"); Console.WriteLine("Press 3 to Change Address"); Console.WriteLine("Press 4 to exit this menu"); int option = int.Parse(Console.ReadLine()); switch (option) { case 1: Console.WriteLine("Enter Your New Home Number"); double hNum = double.Parse(Console.ReadLine()); record.HomeNumber = hNum; break; case 2: Console.WriteLine("Enter Your New Mobile Number"); double mNum = double.Parse(Console.ReadLine()); record.MobNumber = mNum; break; case 3: Console.WriteLine("Enter Your New Address"); string add = Console.ReadLine(); record.Address = add; break; case 4: Console.Clear(); Main(new string[]{"s"}); break; } saveRecord(); } } } public static void Main(string[] args) { // Front end menu Console.WriteLine("----------Menu----------"); Console.WriteLine("Press 1 to enter number (home / mobile)"); Console.WriteLine("Press 2 to exit"); int input = int.Parse(Console.ReadLine()); switch (input) { case 1: enterInPhoneDirectory(); break; case 2: Environment.Exit(0); break; } } Move of the methods are instance methods that aren't declared inside a class definition (and are thus invalid). Several variables aren't declared anywhere, and the aforementioned methods are instance methods rather than static methods. Fixed VERSION: Code: [Select]using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Runtime.Serialization.Formatters.Binary; namespace testapp { using System.Runtime.Serialization.Formatters.Binary; //namespace to use Serialization public static class Program { static ArrayList recordList; static Record records; class Record { private string name; public string Name { get { return name; } set { name = value; } } private double homeNumber; public double HomeNumber { get { return homeNumber; } set { homeNumber = value; } } private double mobNumber; public double MobNumber { get { return mobNumber; } set { mobNumber = value; } } private string address; public string Address { get { return address; } set { address = value; } } // Default Constructor public Record() { this.name = string.Empty; this.homeNumber = 0000; this.MobNumber = 0000; this.address = "Fake"; } // Parameterized Constructor public Record(string n, double hNum, double mobNum, string add) { this.name = n; this.homeNumber = hNum; this.mobNumber = mobNum; this.address = add; } public void print() { System.Console.WriteLine("The Name Is : " + this.name); System.Console.WriteLine(" Home Phone No. Is : " + this.homeNumber); System.Console.WriteLine(" Mobile Phone No. Is : " + this.mobNumber); System.Console.WriteLine(" Address Is : " + this.address); } } // Add a new Record first to ArrayList(recordList) and then in file public static void addNewRecord() { recordList = new ArrayList(); records = new Record(); // Here Adding Record to ArrayList recordList.Add(new Record("osama", 36887676, 3333003212, "Lahore")); recordList.Add(new Record("saad", 4234234, 33330065656, "Ali Park")); recordList.Add(new Record("bilal", 2123456, 0456123232, "Multan")); recordList.Add(new Record("maryam", 1312312, 33330032121, "Karachi")); FileStream fs = new FileStream("data.txt", FileMode.Create, FileAccess.Write); BinaryFormatter bf = new BinaryFormatter(); } // Loads the all reocrds from file and add to ArrayList(recordList) public static void loadRecord() { recordList = new ArrayList(); FileStream fs = new FileStream("data.txt", FileMode.Open, FileAccess.Read); BinaryFormatter bf = new BinaryFormatter(); try { while (fs.CanRead)//Reading the FileStream { Record r = (Record)bf.Deserialize(fs);//De-Serialize the each object recordList.Add(r); //And Add to ArrayList r.print(); //Printing the each record from the file to console } } catch (Exception e) { } fs.Close(); } // Saving the record to file. public static void saveRecord() { FileStream fs = new FileStream("data.txt", FileMode.Create, FileAccess.Write); BinaryFormatter bf = new BinaryFormatter(); for (int i = 0; i < recordList.Count; i++) { var record = (Record)recordList[i]; bf.Serialize(fs, record); fs.Flush(); } fs.Close(); } public static void enterInPhoneDirectory() { var record = new Record(); loadRecord(); Console.WriteLine("Enter Your Home Number/ Mobile Number : "); double number = double.Parse(Console.ReadLine()); // User to enter his/her Home/mobile no. for (int j = 0; j < recordList.Count; j++) { record = (Record)recordList[j]; if (record.HomeNumber == number || record.MobNumber == number) { Console.WriteLine("Welcome , " + record.Name.ToUpper()); record.print(); Console.WriteLine("Press 1 to Change Home Number"); Console.WriteLine("Press 2 to Change Mobile Number"); Console.WriteLine("Press 3 to Change Address"); Console.WriteLine("Press 4 to exit this menu"); int option = int.Parse(Console.ReadLine()); switch (option) { case 1: Console.WriteLine("Enter Your New Home Number"); double hNum = double.Parse(Console.ReadLine()); record.HomeNumber = hNum; break; case 2: Console.WriteLine("Enter Your New Mobile Number"); double mNum = double.Parse(Console.ReadLine()); record.MobNumber = mNum; break; case 3: Console.WriteLine("Enter Your New Address"); string add = Console.ReadLine(); record.Address = add; break; case 4: Console.Clear(); Main(new string[] { "s" }); break; } saveRecord(); } } } public static void Main(string[] args) { // Front end menu Console.WriteLine("----------Menu----------"); Console.WriteLine("Press 1 to enter number (home / mobile)"); Console.WriteLine("Press 2 to exit"); int input = int.Parse(Console.ReadLine()); switch (input) { case 1: enterInPhoneDirectory(); break; case 2: Environment.Exit(0); break; } } } } |
|
381. |
Solve : header link? |
Answer» I am a BEGINNER programmer. I am STUDYING style sheets. My question is...if I have the image of a header that I want to use that I have placed in an IMAGES folder, what is the link format to link to it and where do I put the link? In the header, the css folder or the body? |
|
382. |
Solve : c# add new line to listbox? |
Answer» What my program does and is download a string from and uploaded FILE. I need to ADD a new line to the listbox for every line of string in the downloaded string. If I understand what you're trying to do, you'll have to split the downloaded string first before adding it.Second one worked, thanks a lot. |
|
383. |
Solve : Problem in changing Date and Time...? |
Answer» I want to change my Date and Time... "You do not have a proper privilege level to change the System time" You need to be the admin of the local computer to change the system time. Is this your computer in which you should be the admin, but are not? |
|
384. |
Solve : java working unexpectedly? |
Answer» I want the cyan rectangle to move but it don't. EventQueue.invokeLater(new Runnable() {* MAYBE this is correct for Java syntax, but I am use to seeing a function called that is independent of being enclosed within ( ...... ); multilines, and not structured how you have it with everything contained within a spanned multiline ( ...... ); as I highlighted. I don't program in Java so this may be valid syntaxWell it doesn't show anything as is. I had to change the paint method to get them to show up at all: Code: [Select]public void paint(Graphics frame){ System.out.println("paint"); //super.paint(frame); Rectangle clip = frame.getClipBounds(); frame.clearRect(clip.x,clip.y,clip.width,clip.height); frame.setColor(Color.CYAN); frame.fill3DRect(r1.x, r1.y, r1.width, r1.height,true); frame.setColor(Color.BLUE); frame.fill3DRect(r2.x, r2.y, r2.width, r2.height,true); } The cyan rectangle (r1) doesn't move because the move() method is never called. add move(); before repaint() in the run method. Quote from: DaveLembke on March 05, 2013, 05:04:41 PM * Maybe this is correct for Java syntax, but I am use to seeing a function called that is independent of being enclosed within ( ...... ); multilines, and not structured how you have it with everything contained within a spanned multiline ( ...... ); as I highlighted. It's correct. In fact, the original code could be refactored to completely eliminate move1. right now they are subclassing Thread. this is bad. Don't do this. First, what they ought to be doing is creating a class that implements Runnable, and passing an instance of that class to the Thread constructor. Thread should only be subclassed if you want to add new Thread functionality, not to implement the Run method. Right now: Code: [Select]Thread move1 = new Move1(); My version: Code: [Select]Thread move1 = new Thread(new Runnable() {public void run(){ //infinite loop while(true) { try { move(); //invalidate(); repaint(); Thread.sleep(100); } catch(Exception e) { break; } }}}); This BASICALLY moved the implementation within the class they had that derived from Thread to here. to explain more simply the part that got you confused: that would be the anonymous interface implementation feature of Java. In this case, it's implementing Runnable. A simple example: Code: [Select]private void somemethod(Runnable runner){ runner.run(); } private void main(String[] args){ somemethod(new Runnable(){ public void run(){System.out.println("howdy!");} } ); } (Not formatted well). basically, you can use new with an interface type and define the interface implementation in-line. The DOCUMENTATION is perhaps a more heady source of information. |
|
385. |
Solve : Excel - Add ribbon toolbar to rename files based on filepath? |
Answer» Hi, |
|
386. |
Solve : How to make a batch file that gives an 'Enter' as a result? |
Answer» Hello good morning everyone. |
|
387. |
Solve : need help makeing a batch file to play older games.? |
Answer» Hello all, The computer that I am making the Batch file for is not currently connected to the internet.Then it's exactly the same as the computer I diagnosed this issue with. Quote As there will be no in/outbound connectionsThere will. The functionality will be the same. It will still try to connect, and it will still fail waiting for a response. Quote will the .dll's you listed will hang in an infinite loop?Yes Quote If so, is there any other remedy you can think of to prevent the need for two instances of the same game to run in win7 due to rundll32.exe?The infinite loop is caused by the dlls. Unregistering them prevents them from causing this problem.run: Code: [Select] regsvr32 /u C:\windows\system32\GameUX.dll regsvr32 /u C:\windows\sysWOW64\GameUX.dll Do I paste these into the batch file or do I run them?Either way works. I just ran them at the command line in my situation, but it ought to have the same effect. In my case I don't have Starcraft so this is mostly guesswork based on uncannily similar problems I had with a good number of games when my desktop machine didn't have an Internet Connection. Some of the games I recall having the problem with are from the same era as StarCraft (I BELIEVE the oldest was the Original Command & Conquer), so hopefully your issue is caused by the same thing. Either way, if you ever want to re-register Games Explorer, I think it does so when you launch the Games Explorer, or you can run the same commands but remove the /u switch.Hey, thanks for the help bub ^_^ I was on auto pilot last night. Sleep deprivation and SB DOUBLE shots wouldn't let me accomplish simple tasks. Anyways, I ran the codes via CMDp and they unregistered as you said. I ran Starcraft as usual, but WIN7 is still forcing me to use dual instances of the game before it can be brought to focus. I have installed a couple oldie but goldie games like Warlords battlecry III, C&D, Warcraft III, and still the same deal, all dual instances and I have to Alt-Tab to task manager to kill Rundll32.exe so it will close the first instance of the game and not eat my CPU. I tell you bub, I can have Starcraft II, Dawn of War II, and TES: Skyrim running at the same time, no lag to each other and all three games do not produce over 45 degrees Celsius. This is on my AMD Phenom II 965 BE on STOCK cooler. (cherri wewt!) But if I got to run a single game game from the 90's my CPU is hitting 60c on loading the game, and 65-70 while playing the game unless I kill rundll32.exe. Even then it is still running in the 50's for these old games. If you can think of a for starcraft as said originally, the .bat is a bit more complicated as it needs to both end explorer and kill rundll32, but for the other old games, I need only kill rundll32 via batch file just to make my gaming a bit easier. So if you know a way to make a batch file that can accomplish this task, I would be very grateful for the information. ^_^ Either way, I do really appreciate all the advice. I will know what to do in the future if I run into the infinite loop issue in the future.You could always figure out what the rundll32.exe is for, hopefully it could give a clue as to an underlying CAUSE. In Task Manager, you can add the "Command Line" column; this column on rundll32.exe will tell you/us exactly what dll is involved. In my investigations of my issue, it was GameUX.dll; but if you unregistered that it shouldn't be appearing, so it must be something else. Also double check the path of the rundll32.exe file, and make sure it is in C:\Windows\System32 or C:\Windows\SysWOW64. You can kill rundll32.exe in a batch file the same way you kill explorer. The problem is it probably doesn't appear until after you've launched it, and by that time the batch is no longer in control (I imagine you have it wait for the program to exit so that you can launch explorer again). I suppose you could delay using ping. Either way I imagine there is an underlying cause, and the command line of the pegging rundll32 process can be useful to find out why. |
|
388. |
Solve : [VB .Net] Pick a random entry in a List(string)? |
Answer» Pretty much I have: I realise this is an old thread but I was wondering what ('* li.Count - 1)))' did in the code above.....the value used is li.Count-1 because the Items Accessor is zero-based. However, even so there is actually a bug in the original solution that prevents the last element of a list from ever being chosen. It's actually a bug, somewhat. I used -1 because the Item accessor method takes a zero-based index and li.Count retrieves the total NUMBER of elements, so a 4-item list would return 4 for Count, but the fourth item would be accessed with li.Items(3). However, the "bug" is because rnd returns a number between 0 and 1 exclusive- that is, the resulting value will never be 1. The Int function truncates the value, so the resulting index will never actually be the last index of the list. The bugfix would be to use Math.Round instead of Int(): Code: [Select]li.Item(Math.Round(Rnd() * (li.Count - 1))) Full disclosure, I didn't actually use the original code, so it wasn't fully tested. My preferred method of choosing an Item from an Array or other collection is a Generic Method I wrote in C#. To make ammends for my 4 year old transgression, I will post that here, after porting it to VB.NET. The original C# implementation was called "Choose" and so was my VB.NET version until I noticed the existence of the legacy Choose() Function from VB6, when I renamed it to "Pick": Code: [Select] Public Function Pick(Of T)(ChooseArray As IEnumerable(Of T)) As T If rgen Is Nothing Then rgen = New Random() Dim sorttest As SortedList(Of Double, T) = New SortedList(Of Double, T)() For Each loopvalue As T In ChooseArray Dim rgg As Double = rgen.NextDouble() Do While sorttest.ContainsKey(rgg) rgg = rgen.NextDouble() Loop sorttest.Add(rgg, loopvalue) Next Return sorttest.First().Value End Function As a generic method, it works with an Array of Any type, and Any collection, because it accepts any IEnumerable implementation. If one is targeting VB11, you can even use the ported version of the method that acts as an Iterator Method: Code: [Select] Public Iterator Function Pick(Of T)(ChooseArray As IEnumerable(Of T), NumItems As Integer) As IEnumerable(Of T) If rgen Is Nothing Then rgen = New Random() Dim sorttest As SortedList(Of Double, T) = New SortedList(Of Double, T)() Dim ResultTest As List(Of T) = New List(Of T) For Each loopvalue As T In ChooseArray Dim rgg As Double = rgen.NextDouble() Do While sorttest.ContainsKey(rgg) rgg = rgen.NextDouble() Loop sorttest.Add(rgg, loopvalue) Next Dim I As Integer Dim DictEnumerator As IEnumerator(Of KeyValuePair(Of Double, T)) = sorttest.GetEnumerator() Do While DictEnumerator.MoveNext() And NumItems > (I) Yield DictEnumerator.Current.Value I = I + 1 Loop End Function The test Code I used that shows these methods being used: Code: [Select] Sub Main() Dim SelectFrom As Integer() = Enumerable.Range(0, 100).ToArray() For I As Integer = 0 To 100 Console.WriteLine(Pick(SelectFrom)) Next For I As Integer = 0 To 100 For Each iterate In Pick(SelectFrom, 4) Console.Write(Str(iterate) + ",") Next Console.WriteLine() Next Console.ReadKey() End Sub |
|
389. |
Solve : Problem getting loop to restart on error Javascript? |
Answer» I am trying to get my loop to go back to the beginning on the first error. I am trying to get my loop to go back to the beginning on the first error. |
|
390. |
Solve : modify batch script to delete files? |
Answer» So Sidewinder helped me create a .bat and .vbs script that work like a charm. But now I need to modify it to delete all .zip files older than a week old. I have tried various methods and i seen the main method is to use forfiles but i can not install that on any computers. So doing it via batch would be perfect if i have to use another .vbs script that is fine to but prefer .bat May I ask a question? For less clutter. Thats why if it can be added to the zip.vbs that would be awesome if not in the batch that is fine too. been researching this like crazy.Here is a post that might be relevant to what your want. Need a VBScript that calls a batch file to run on remote computers Hope that helps some. Quote from: Geek-9pm on September 04, 2013, 03:18:55 PM Here is a post that might be relevant to what your want. What I am working on is not for remote. Thanks for the assistance. I think this is what you need. The only issue is it will not look for files in subfolders. You just need to uncomment the deletefile part and change the path. Code: [Select]Set objFSO = CreateObject("Scripting.FileSystemObject") objStartFolder = "D:\htdocs" Set objFolder = objFSO.GetFolder(objStartFolder) Set colFiles = objFolder.Files nowDate = Date For Each objFile in colFiles fileDate = objFile.DateLastModified howLong = DateDiff("w", fileDate, nowDate) If howLong > 1 then wscript.Echo objFile.Path 'objFSO.DeleteFile objFile.Path End If Next Quote from: Linux711 on September 04, 2013, 07:06:08 PM I think this is what you need. The only issue is it will not look for files in subfolders. You just need to uncomment the deletefile part and change the path. Should I add this to the zip.vbs file or create a new file and add the code there? |
|
391. |
Solve : Asm+batch?? |
Answer» Help, computer problem after file recovery(pictures), bios takes longer to load and windows too, when computer is idle cpu and gpu GOES to 100%, mouse click 2 times sometimes... I once see a question mark in hex editor in between hex of a HARD drive mft then format and it was gone. I think 100% that something is wrong with my pcNo there isn't. Quote I was trying to learn batch commands and dos so I could synchronise data buffers or somethingThis is a nonsense phrase. It doesn't make any sense. Quote and trying to learn asm so I coul read cmos many times or write 1 values to see where it goes wrong but no sucsses.This doesn't make much sense either. Why would you want to read the CMOS RAM many times? Surely once would be sufficient. (Of course let's ignore the fact that you aren't running DOS to begin with, thus you don't actually have real-mode access to the system but (if you are on 32-bit) are actually given access to a virtualized Processor through NTVDM. On 64-bit there is no Debug and there is no simple way to assemble and run 16-bit Assembly programs from within the OS. Quote I remember pluging hard drive broken by file recovery to a working pc and there were only 254 sectors one missing, and after restart 255 sectorsHard Drives use LBA now. Sectors are always 255. Some informational tools will show 254, since they will count the first one as Sector 0. Quote but some values missing in cmos and seetings in cmos wrong load defaults... so the first one is missing or is it it starts with second bit?The CMOS has nothing to do with your Hard drive. I'm honestly not sure if you are trolling or are seriously this uninformed on the concepts that we've so far tried to explain, but which have so far been ignored. You cannot just make up phrases and terms and think we'll know what you mean. Quote Could some Expert tell me is it the data buffers or what?I cannot rightly apprehend the confusion of ideas that would lead to such a question. Quote http://youtu.be/Id7GCd4SY_UIt's a glitch related to combination of using a internal command name for the name of the batch script (for) calling a batch script with that internal command name, but using a forward slash to trick the parser into calling the batch rather than the internal command, and continuing the call it until it ends up exiting. In this case the Error CODE that causes CMD to crash is "c00000fd", which is Stack Overflow. I would surmise that some combination of using the internal command name for the batch script, the batch script chaining to itself, and the use of a forward slash at the end of the name causes this problem. Quote from: Mflipb on August 30, 2013, 07:17:55 AM I rember the repair man was like "writing ones to buffer host ide or something cmos without reading next data buffer clock to get data buffer to beginning" This entire post is unintelligible. The repair man also said that a=bc that C is actualy A and need to change it, after he filled some memory with ones #1 , does that make any sense im writing to you what he did to repair my pc im not making things up and I don't know anything about programing trying to learn... Quote from: Mflipb on August 30, 2013, 11:55:40 AM The repair man also said that a=bc that C is actualy A and need to change it, after he filled some memory with ones #1 , does that make any senseNo, that makes no sense. I say this character is a fairly obvious "attention troll", probably aged about 12. His outpourings remind me of the "stuff about computers" in novels written by people who don't actually know anything about computers. I remember one of the Kay Scarpetta novels by Patricia Cornwell where she goes on about "formatting a few files" and other nonsense. Quote from: Mflipb on August 30, 2013, 07:07:44 AM I was trying to learn batch commands and dos so I could synchronise data buffers or something Or something? Or something? He's yanking your chains and not even hiding the fact. yes I was having trouble deciding if this was somebody who had a prenatal lobotomy or somebody who was purposely making absolutely no sense. I was leaning towards the latter.Time to reformat. This thread is beyond recovery. Note to the OP. What do you want to do? Is the issue saving a picture? You should export your pictures to some kind of permanent t media, like a CD-R you burn in a CD-EOM drive. Problems with pictures have nothing to do with the hard drive geometry. Pictures and never stored in CMOS. An many technicians know the difference between a Phillips head screwdriver and the other kind. That is how they got to be technicians. And when not working on computers, they shoe horses. If you want to go back to Windows XP and start over again, you have my permission. But But if you keep using Windows 7, please do not post any more questions like the ones you did here. In Windows 7 programmers do not use the DEBUG tool from early versions of Windows. It just don't work right. And nobody here will help you work on the MBR in Windows 7. In Windows 7, the MBR is not for any user programming or modification. That is by design. But we are willing to help. Just no more DEBUG with Windows 7. For the benefit of all readers, here is a simple explanation of what CMOS meas with reference to a PC. http://www.wisegeek.org/what-is-cmos.htm#slideshow (Also has pictures of other common PC parts.) |
|
392. |
Solve : Python - Accessing information buried in a dictionary? |
Answer» Hi, SORRY for the noob question. I've just (re)started trying to understand Python, and decided to start with trying to make a script to create a personalized weather report. |
|
393. |
Solve : Need C Programming Help! (tinker with program)? |
Answer» So, to begin, I must write a program that I can type in a number of inches and it will list how many miles, yards, feet and inches I entered. With this program I keep getting the error: |
|
394. |
Solve : How should I structure this XML file?? |
Answer» I am making my first XML file and I'm trying to decide the best way to structure the data. It contains a LIST of file types and their CORRESPONDING description and some other info. |
|
395. |
Solve : Need an OOP example? |
Answer» Hi, |
|
396. |
Solve : New, again, with BASIC? |
Answer» This is my first posting here. I did some BASIC programming back in the mid-1980s and now decided I wanted to get back into it again. This attached program was my first new attempt at it, using QB 1.1. I've since gotten into QB 4.5 and like it much better. One suggestion I have is to accept both Upper Case Y and Lower case y such asBasic and variants use AND and OR. Either way, a better approach would probably be a function. StrComp is a function found in more recent Versions of Visual Basic. It is not present in older QBASIC and QuickBASIC packages, but you can write a Version of it: Code: [Select]CONST FALSE = 0 CONST TRUE = NOT FALSE DECLARE FUNCTION STRCOMP(str1 AS STRING, str2 AS STRING, COMPARETEXT AS INTEGER) FUNCTION STRCOMP(str1 AS STRING, str2 AS STRING, COMPARETEXT AS INTEGER) IF COMPARETEXT THEN STRCOMP=(UCASE$(str1)=UCASE$(str2)) ELSE STRCOMP=(str1=str2) END FUNCTION Not tested, I'll admit. Speaking of Functions and subroutines, I notice a distinctive lack of them in the provided source listing, instead using GOTO for most of the flow control. Aside from that, you might want to consider looking into more modern alternatives. If not Visual Basic, then something like FreeBASIC. FWIW, your provided source listing compiles and runs with the freeBASIC if the "-lang DEPRECATED" flag is PASSED to the compiler. (it does provide a warning about a variable). I know this does not directly pertain to your question, but I think you should give QB64 a try. It is a modern remake of QB and is almost completely syntax compatible. If you are not just doing this for fun and actually want to gain some programming skills, you should choose a more modern programming language as BC suggested (maybe C#) because once you learn that one, most other programming languages will just fall into place; it wont take much learning time because of the similarities.First - A big thank you to DaveLembke, BC_Programmer and Linux711 for your suggestions and help. I appreciate your interest. Dave: I tried your suggestion for accepting both upper and lower case of a letter. As you suspected the && (AND) || (OR) will not work in QB 4.5. I modified it to a syntax that does work; see my attached file, BOTHCASE.txt. Thanks for the offer for additional assistance. BC_Programmer I must admit I'd never heard of the "StrComp," function and the code you provided is a little above me at this point. You make a good point about functions and subroutines. I can see where that is better than using GOTO for most of the flow control. Linux711 I'll add your suggestion to my list of apps to try. So now my list has: 1. QB64 2. Visual Basic 3. FreeBasic 4. QB64 I am doing this for fun but also want to gain some programming skills. [recovering disk space, attachment deleted by admin]I think it would be simpler to convert the ENTER$ variable to an uppercas before it goes to the if statement. I believe to do so you type: UCASE$(ENTER$) In your code. Quote from: Newbe on January 27, 2013, 12:36:29 PM Dave: I tried your suggestion for accepting both upper and lower case of a letter. As you suspected the && (AND) || (OR) will not work in QB 4.5. I modified it to a syntax that does work; see my attached file, BOTHCASE.txt. Thanks for the offer for additional assistance. Original Code: [Select]CLS PRINT "Would you like to print this information?" INPUT "ENTER 'Y' for YES"; Enter$ IF Enter$ = "y" THEN Enter$ = "Y": GOTO PrintIt IF Enter$ = "y" THEN GOTO PrintIt IF Enter$ <> "y" THEN IF Enter$ <> "Y" THEN GOTO RUSure PrintIt: PRINT : PRINT "Print it": END RUSure: PRINT : PRINT "Not print it": END What about: Code: [Select]CLS PRINT "Would you like to print this information?" INPUT "ENTER 'Y' for YES"; Enter$ Enter$ = UCASE$(Enter$) IF Enter$ = "Y" THEN GOTO PrintIt GOTO RUSure PrintIt: PRINT : PRINT "Print it": END RUSure: PRINT : PRINT "Not print it": END Or, changing it to use structured programming, rather than "street BASIC" stuff (I think I'll describe that in a bit): Code: [Select]CLS PRINT "Would you like to print this information?" INPUT "ENTER 'Y' for YES"; Enter$ Enter$ = UCASE$(Enter$) IF Enter$ = "Y" THEN PRINT "Print it" ELSE PRINT "Not print it" END IF END That is essentially what you are "emulating" using the street BASIC goto. GOTO was the only control structure you could use in some early BASIC interpreters for Personal Computers. However, there hasn't been a good reason to limit yourself to using GOTO as the only method of flow control. It makes things more difficult to follow, and as programs get larger, it can become impossible to keep track of all the control flow. This applies equally to "GOSUB"; GOSUB works basically like GOTO, but you can make it return to where you used it with RETURN. For example: Code: [Select] CLS PRINT "Would you like to print this information?" INPUT "ENTER 'Y' for YES"; Enter$ Enter$ = UCASE$(Enter$) IF Enter$ = "Y" THEN GOSUB PRINTIT ELSE GOSUB NOPRINTIT END PRINTIT: PRINT "Print it" RETURN NOPRINTIT: PRINT "Not print it" RETURN END This is functionally identical to the above. Naturally the appropriate logic would go within each, as I imagine you are implying with your own example. Quote BC_Programmer I must admit I'd never heard of the "StrComp," functionStrComp isn't in QuickBASIC, or most older BASIC dialects. I was thinking of Visual Basic. Quote and the code you provided is a little above me at this point.My code was in error, actually. The purpose is to create a new Function- STRCOMP, for comparing strings. Though perhaps a stumbling block for you is that you don't appear to be using Functions at all. EXAMPLES of common functions include LEFT$(), RIGHT$(), etc. StrComp() as present in languages that have it- unsurprisingly- compares the two strings you give it. if the first string is less than the second in the sort order, it returns -1; if they are equal, it returns 0. and if the second string is smaller, it returns 1. Now, I quite recall my initial hurdles learning about Functions. The best way I found to consider them is more or less like a Math function. For example, math usually portrays math functions as f(x), which performs some function f on the value x. Most BASIC dialects include common Functions such as SIN, COS, and TAN. A Function, then, usually has a few basic properties. -A Name. This is pretty obvious. You need a name for a function so you can call it and use it. -Arguments. Most functions take in inputs. for example, the trigonometric functions accept a number. This isn't required, though. -A return value. This is what the function gives you back. Now, in the case of StrComp, we have the following: The Name will follow the standard "convention" of QuickBASIC, which is all uppercase function names. I think it looks ugly and makes the code look like it's yelling but when in Rome... Anyway, the name here will be STRCOMP. Arguments. Our function will compare two strings. So we will need to accept two strings as arguments. We also want a argument to determine whether we will be case insensitive. We will accept an "INTEGER" number value. 0 will MEAN we don't want to compare text, and 1 will mean we do. ("Compare Text" meaning to be case insensitive) QuickBASIC's rules regarding functions means we have to "DECLARE" it before we use it. This isn't 100% necessary but it's a good habit anyway. The line is essentially used to tell the compiler "I'm going to be using a Function, if you don't know what it does when you see it, don't worry, I'll tell you". Code: [Select]DECLARE FUNCTION STRCOMP(BYVAL str1 AS STRING,BYVAL str2 AS STRING, BYVAL COMPARETEXT AS INTEGER) AS INTEGER the Function is declared with two String Arguments, and one INTEGER argument. the final section says the type of the Function's return value. in this case, INTEGER. BYVAL is worthy og explanation as well. This says that the Function will accept the parameters "By Value". In other words, when you call the function, the function get's a copy of what you sent it. This prevents the Function from changing those parameters, which can cause side effects later on. Here is the implementation: Code: [Select]FUNCTION STRCOMP(BYVAL str1 AS STRING,BYVAL str2 AS STRING,BYVAL COMPARETEXT AS INTEGER) AS INTEGER IF COMPARETEXT THEN str1 = UCASE$(str1) str2 = UCASE$(str2) END IF iF str1<str2 THEN STRCOMP=-1 IF str1=str2 THEN STRCOMP=0 IF str1>str2 THEN STRCOMP=1 END FUNCTION The first step we take is to check if the passed in COMPARETEXT argument is non-zero. This satisfies the IF condition, and we then change the two input strings to be the uppercase versions of themselves by assigning the result from the UCASE$() function on them. After that, we simply follow the convention. "return" values are set by assigning values to the name of the function. In this case, we set the appropriate values to STRCOMP inside the function. The last thing we assigned when the function exits will be used in place of the function call. Some examples: Code: [Select]PRINT "StrComp test." PRINT STR$(STRCOMP("False","FALSE",0)) PRINT STR$(STRCOMP("Turkey","Monkey",0)) PRINT STR$(STRCOMP("Animal","Weasel",0)) Quote Linux711 I'll add your suggestion to my list of apps to try. So now my list has:FWIW your budget program works fine in QB64 as well. QB64 is available here Dear OP, If you are comfortable with QB 4.5 just keep using it. You can make code that is both easy to read and efficient. You can define procedures and functions in QB 4.5 as well as different types of variables. And the ability to handle binary files in QB if very good. You don't need to learn another computer language unless you want to. Any language that does what you want is what you want. Age does not matter. If someday QB will not run on a new OS, you just put it in a VM and keep working. BYW, Fort ran is still around and does some very cool things. Once again my thanks to BC_Programmer for all the help. Geek-9pm: I appreciate your comments also.Several folks had suggested QB64 as a next step. So when BC_Programmer told me that my "budget program works fine in QB64 as well. QB64 is available here" I clicked the "here" link, downloaded, and installed QB64. It works fine and I like it but there is one thing I can't figure out how to change. I figured out how to get the editing window to full screen. But when I run the .bas program it goes to another window which is about 1/4 the size of my screen. In QB45 the program runs in the same window in which the code is entered, while QB64 opens a popup window of about 1/4 the size of the full screen; at least that's what mine does. I tried running QB64 with a desktop shortcut to qb64.exe and with the following desktop .bat file: cd\qb64 'Directory on my C: drive where qb64.exe is located. qb64.exe What am I missing?http://qb64.net/wiki/index.php?title=FULLSCREENThanks Linux711. I'll let you know how it works out. I haven't tried it yet in a program. It may be a few days though, since I have other stuff going.OK, I tried QB64 and can readily see how much it is advanced over QB45. However, at least on my Win XP machine, it is cumbersome for me - I guess it's just too much for me to absorb at once. I wrote the attached program in QB45 and do like the way it looks there - as a 2nd effort anyway. I ran this same code on QB64. It does run but: it opens in a window 1/4 the size of my monitor screen; the top section of the first screen has a blue background for the top half (as I intended) but black for the bottom half. The rest of the program runs the same as in QB45, just in the small window. There are other items, which I don't need to get into now. My main goal now is composing efficient code. Comments? [recovering disk space, attachment deleted by admin]Comments? Frankly I do not see any need to run this kind of program in 64 bit mode. To the best of by knowledge there is no advantage to letting a small progrm have more memory space than it could possibly use. The code yon provided will compile to a EXE that takes less that a megabyte. And the data space is uses is trivial. Am I missing something here? Quote from: Geek-9pm on February 08, 2013, 09:42:51 PM Comments?-QB64 is a 32-bit program, not a 64-bit one. -Original QB's data usage is severely limited, as a result of not having access to a Virtual Memory manager. (Go ahead, try to find all the anagrams in a 200K+ Dictionary). -64-bit Programs do not use more memory space. They have the capability to access more memory, though. Also: QB64 appears to auto-update. Though that one could go either way. It is actively developed, however, which is a plus. As for efficiency: Switching to subroutines and functions will speed up the code significantly. GOTO of course compiles to an Assembly JMP instruction. The issue with it is that it often wreaks havoc on the CPU prefetch cache, and basically every JMP will flush the prefetch queue. CALL and RET- which are used for functions and subroutines- work with the prefetcher logic. This wouldn't have a impact on your program- your program is currently fine, since most of it's time is spent waiting for user input. |
|
397. |
Solve : for command question? |
Answer» This SEEMS to simple to be asking for help but here goes, help! What am I missing that won't allow the for command to capture the entire line past the space character? You are mistaken in thinking that tokens=1 will compress the whole line into the %%A metavariable. What the tokens=1 element does is take the line up to the first delimiter and put that first token into the EXPLICIT FOR metavariable (%%A in this case). If there were more tokens specified by numbers they would (assuming they were present in the line) be assigned to implicit metavariables starting with the next letter of the alphabet in the same case (here, %%B). Spaces and tabs are the fault delimiters if no other(s) is (are) specified using delims=. If you want to get the whole line into %%A you need to specify that the delimiter is the end of the line. That is, delims= followed by the closing double quote of the options BLOCK. You can do so like this FOR /F "usebackq delims=" %%A IN (C:\temp\file_path.txt) DO ( By the way, in the filespec there needs to be a colon after the drive letter. You are using usebackq when you don't need to. Thanks. That did it. |
|
398. |
Solve : Why doesn't my timer work?? |
Answer» I have a well-DEFINED derived CWnd class, say myClass. I set a timer at beginning: SetTimer (999, 1000, 0) inside a member function of myClass. |
|
399. |
Solve : Migrate Console App to Windows 32 App C++? |
Answer» I have a program that I wrote up in C++ as a Console App using Bloodshed Dev C++ 4.9.9.2 and it works perfectly fine. But the interface is ugly as can be expected from the limitations of working in a Console App environment. |
|
400. |
Solve : Batch: size of folders from a list? |
Answer» Hello, |
|