Microsoft KB Archive/196575

= PRB: DhCell.getValue Returns 0 for DhCell w/o Integer Value =

Article ID: 196575

Article Last Modified on 8/25/2005

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition

-



This article was previously published under Q196575



SYMPTOMS
The setValue and setText APIs set the value of a DhCell.

If setText is called with a non-integer value, the DhCell is assigned a value of 0.



STATUS
This behavior is by design.



MORE INFORMATION
The value of a DhCell is set by calling either the setValue or the setText method.

The following four instructions yield a value of zero because setText is called with a non-integer value: DhCell cell=new DhCell; // Create a DhCell element. cell.setValue(10);  // The value of the cell is 10. cell.setText("Hello"); // The value of the cell is now 0. int cellValue = cell.getValue; // cellValue=0. The following four instructions yield a value of 123 because setText is called with an integer value (123): DhCell cell=new DhCell; // Create a DhCell element. cell.setValue(10);  // The value of the cell is 10. cell.setText("123"); // The value of the cell is now 123. int cellValue = cell.getValue; // cellValue=123.

Steps to Reproduce Behavior
 Create a default Code-Behind HTML project using Visual J++ 6.0. To do this, click New Project... from the File menu. Click the New tab in the New Project dialog box. Select Web Pages from the Visual J++ Projects tree. Select Code-Behind HTML, and click Open to create the project. Class1.java is created by default.  Modify Class1.java as follows: import com.ms.wfc.html.*; import com.ms.wfc.core.*; import com.ms.wfc.ui.*; public class Class1 extends DhDocument {  public Class1 {     initForm; }  private void initForm {  }   protected void onDocumentLoad(Object sender, Event e)   { DhTable table=new DhTable; table.setBorder(1); add(table); DhRow row=new DhRow; table.add(row); DhRow row2=new DhRow; table.add(row2); DhCell cell=new DhCell; row.add(cell); cell.setValue(5); row2.add(new DhCell("value:"+cell.getValue)); // 5

cell=new DhCell; row.add(cell); cell.setValue(12); cell.setText("HelloWorld"); row2.add(new DhCell("value:"+cell.getValue)); // 0

cell=new DhCell; row.add(cell); cell.setText("-10"); row2.add(new DhCell("value:"+cell.getValue)); // -10

cell=new DhCell; row.add(cell); cell.setText("38.3"); row2.add(new DhCell("value:"+cell.getValue)); // 0 } }                         Modify Page1.html as follows:      

<FONT color=BLUE> <SPAN id="coloredText">Testing...</SPAN> </FONT> </BODY> </HTML> </li> Run the project.</li></ol>

RESULT: You will get the following web page: <pre class="fixed_text">  5         HelloWorld    -10          38.3 value:5  value:0       value:-10    value:0

<div class="references_section">