i.e. \nto extract an integer you can use the syntax\nid = Integer.parseInt(idfld.getText());\n\nim trying something similiar like.\ncode = Character.parseChar(codefld.getText());\n\nan I close, is it possible... please someone help, your my only hope. finals are monday.
201156
You may use the charAt method which receives an integer index as a parameter and returns the character in the String that's positioned at that index.\n\nString s = "Hello";\nSystem.out.println(s.charAt(0)); =>This would print the H\n\nThe toCharArray method would convert the String to an array of characters containing the same characters as those in the String.\n\nchar[] C=s.toCharArray(); => C{'H','e','l','l','o'}
237903
Instead of:\n\nif (Month < 01 && > 12);\ncout<< "Please enter a valid Month in 2 digit format&#92;n";\n\nYou should write:\n\nif (Month < 1 || Month > 12) {\n  cout<< "Please enter a valid Month in 2 digit format&#92;n";\n}\n\n1) Don't put a semicolon after the closing ).\n2) Don't prefix numbers with a 0. The compiler treats these as octal numbers.\n3) The expression in your if statement is incorrect. \n3a) You are using && (and) instead of || (or). A number can't be both less than 1 and greater than 12.\n3b) You need to write the variable name once for each expression in your if statement.
236929
Well I can't tell u how to do it b/c that would be wrong. But yes. You have to use IndexOf, IsNumeric, substring, and focus. So yes u are the right track. Contact me at free_best_jack@yahoo.com if you have any more questions.
146317
If you want to convert a hex string to decimal, you\nneed to do two operations:\n\n- convert the hex string to a number\n- generate a decimal string from that number\n\nIf your system supported a full C implementation,\nit would be as simple as using scanf()/printf().\nI presume you're being asked to implement the\nprimitives yourself :-)\n\nTo convert a hex string to a number, you might\nimplement something like:\n\nint number = 0;\nwhile ((c = getchar()) != '&#92;n') {\n  if (c >= '0' && c <= '9')\n    number = (number<<4) + (c-'0')\n  else if (c>='a' && c<='f')\n    number = (number<<4) + (c-'a')\n  else if (c>='A' && c<='F')\n    number = (number<<4) + (c-'A')\n}\n\nThis could be cleaned up if you have access to the\n<ctype.h> macros [ie. isdigit() and tolower()].\n\nTo convert the number to a decimal string, you need\nto perform successive divisions by 10.  An 8051\ndoesn't have a hardware divide, but that's OK\nbecause you should have a software divide/remainder\nsubroutine.\n\nThere are two tricks to keep in mind.  First to\ngenerate the appropriate character for each digit,\nyou can treat a literal character string as an\narray.  For example:\n\nchar c = "0123456789ABCDEF"[i];\n\nwill assign the correct character to variable "c"\nbased on the value of "i" (if it is between 0 and\n15).\n\nThe other detail is that as you call the divide/\nremainder subroutine, you will generate the digits\nworking from least significant to most significant.\nTherefore, you'll want to fill an array from right\nto left.  Assuming you have a divide routine with\nthe prototype:\n\nint\ndivide(int dividend, int divisor, int *remainder)\n\nand you can use the "puts()" function to display the\ngenerated string, you might use something like:\n\nvoid\ntodecimal(int value)\n{\n  char buffer[20];\n  char*p = &buffer[sizeof(buffer)-1];\n  int remainder;\n  while (value != 0) {\n    value = divide(value, 10, &remainder);\n    *p-- = "0123456789ABCDEF"[remainder];\n  }\n  puts(p+1);\n}
59598
ok, to split a string\n\nuse this code\n\ndim s1 as string = ("dog")\n\n Const d As Char = "d"c\n Const o As Char = "o"c\n Const g As Char = "g"c\n        Dim delimiters() As Char = {d, o, g}\n        Dim resultArray As String() = s1.Split(delimiters)\n\nFor Each substring In resultArray\n            ctr = ctr + 1\n            output &= ctr.ToString()\n            output &= ": "\n            output &= substring\n            output &= Environment.NewLine\n        Next substring\n        Console.WriteLine(output)\n\nhope that sorts that out\n\nR3dm0
333332
SQL has got a convert(datatype(size,precision),value) method\n eg:convert(decimal(18,2),12345.6789) as no_with_10.2_precisoin\n\nu should be able to use it to convert ur string to small int too. but make sure u validate the entry before sending to sql (avoid a typecaste error)
37744
I rember doing something like this: you had to take the int you store the input in, and divide it by ten with the mod operator (%), and store it in a new int.  Since the mod operator divides the two numbers, and then returns the remainder, that will separate your last number.  For example:\n\nSay the input is 4321, and you have it stored in int input;\n\nint first_num = input % 10;\n\nthis takes your value in input, divides it by 10, then takes the remainder and stores it in first_num.  In this case, first_num should now equal 1.  \n\nAfter that, you have to shorten your input from 4321 to 432 by dividing (regular dividing this time) it by ten, and storing it in another new int.  (Since int can't have any decimals, dividing by ten just shortens it by the first number).  Then you do the whole thing over until you have all four numbers in separate ints, and then output them to separate lines.  \n\nHope that's clear enough--it's hard to explain this stuff so it's easy to understand.  Good Luck!
374517
Dim i, total As Integer\ntotal = 0\nFor i = 0 To Integer.Parse(TextBox1.Text) Step 2\n     total += i\nNext\nMsgBox(total.ToString())
614370
You must cast legs to an integer using parseInt\n\nlegs = parseInt(legs);
103584
Assuming:\n1. You are using VB.NET\n2. The actual number will be intResult\n3. The guess will be intGuess\n\nWe need to know what Dozen Bet the guess, and the result, belong to. We do that with the following function:\n\nFunction DozenBetBlock(intInput As Integer)\n...Dim intBlock As Integer\n...Select Case intResult\n......Case < 13:\n.........intBlock = 1\n.........Exit Select\n......Case < 25\n.........intBlock = 2\n.........Exit Select\n......Case Else\n.........intBlock = 3\n...End Select\n...Return intBlock\nEnd Function\n\nAnd then, we simply call the function on both the result and the guess to find out if there was a win:\n\nIf DozenBetBlock(intResult) = DozenBetBlock(intGuess) Then\n...Console.Write("Hooray! You have won the dozen bet!")\nEnd If\n\nIn the code above, delete the periods at the start of each line. I added them for spacing purposes only, since Answers will not show tabs.
605411
Try using String.Format()\n\nFor example:\n\nString.Format("Hello {0}, you are {1}",\n      value1,\n      value2)
2286
alternative 1)\nUse int/short instead. Make sure you mask potential values with "& 0xff" so they don't overflow.\n\nalternative 2)\nUse (signed) byte for storage, but when doing comparisons, assignment to other integer types, cast to int/short and mask with 0xff
41040
You could do something like:\n\n\nDim captionString As String\nDim numEntries As Integer\nDim ctr As Integer\nnumEntries = 0\n\nFor ctr = 1 to Len(txt.text)\n    If (Mid(txt.Text, ctr, 1) = "a") Then\n        If (numEntries > 0) Then\n            captionString = captionString & ","\n        End If\n        captionString = captionString & ctr\n        numEntries = numEntries + 1\n    End If\nNext ctr\nLabel1.Caption = captionString\n\nThe idea is that everything inside the For...Next loop is done at each position of the string, and so you build up the string to put in the caption of Label1.
8403
Scott's code won't work if the numbers can be negative.\n\nYou can find the upper and lower bound as you read the file into the array.\n\nConst MAXFILESIZE = 1000\nDim lowBound as double, hiBound as double\nDim val as double\nDim ln as String, i as Integer\nDim dataTable as String(MAXFILESIZE)\n\ni = 0\n' Get initial values from first line of file\nln = Console.Readline()\n' Should check ln != null\ndataTable(i) = ln\nval = CDbl(ln)\nlowBound = hiBound = val\nwhile (ln != null)\n   i = i + 1\n   ' Read a line\n   ln = Console.Readline()\n   ' Put data into the table\n   dataTable(i) = ln\n   ' Adjust bounds if necessary\n   val = Cdbl(ln)\n   if val > hiBound then\n      hiBound = val        ' remember i?\n   elseif val < lowBound then\n      lowBound = val       ' remember i?\n      end if\n   ln = Console.Readline()\n   end while\n\n(Sorry about the formatting -- that's Yahoo's doing.)
9060
int main()\n{\n   int age, feet, inches, pounds;\n   string hair, eye;\n}\n\n\nint means integer, string is something like "brown", "mary had a little lamb", etc\nyou can also do char to define a letter varible, or char can be used as a string by declaring a character array.
392336
you need to cast the value. try this\n\nDouble.parseDouble(someStingValue);\nyou can use the variable as a double then.
508575
Public Function FindDelimitedString(ByVal s As String, ByVal startDelimiter As String, ByVal EndDelimiter As String) As String\n        Dim beginPosition As Integer\n        Dim endPosition As Integer\n\n        If (s.Length > startDelimiter.Length + EndDelimiter.Length) Then\n            beginPosition = s.IndexOf(startDelimiter)\n\n            If (beginPosition >= 0) Then\n                beginPosition = beginPosition + startDelimiter.Length\n                endPosition = s.IndexOf(EndDelimiter, beginPosition)\n                If (endPosition >= 0) Then\n                    Return s.Substring(beginPosition, endPosition - beginPosition)\n                End If\n            End If\n        End If\n\n        Return String.Empty\n    End Function