I want to increase my knowledge of PHP by learning about classes. I wrote the following very simple test program. It works. But I would like to know improve it. I plan on writing more complex test programs and that won't be the time to iron out smaller issues. Thanks in advance. <?php $length = array_key_exists('length', $_POST) ? $_POST['length'] : null; $width = array_key_exists('width', $_POST) ? $_POST['width'] : null; if ($length == "") $length = 0; if ($width == "") $width = 0; ?> <?php class Shape { var $length; var $width; function setLength($Length) { $this -> length = $Length; …

Member Avatar
Member Avatar
+0 forum 28

I need to change the background image of a button that is declared in xaml, like this: <Button x:Name="btnBorder" Content="Moldura" Width="80" Height="80" Margin="10,6,10,6" Click="btnBorder_Click" > <Button.Background> <ImageBrush ImageSource="/Images/arrow-expand.png" AlignmentX="Center" Stretch="None" x:Name="imgSourceArrow" /> </Button.Background> </Button> and I'm trying to change the ImageSource of the ImageBrush. For that, I'm using this code in the code-behind: ImageBrush imgb = new ImageBrush(new BitmapImage(new Uri("/Resources/arrow-expand.png"))); W.btnBorder.Background = imgb; But when I run the Application, I get an error "UriFormatException was unhandled", "Invalid Uri"... How can I reference the "arrow-expand.png" image inside the resources and transform it into an Uri String to be passed into the …

Member Avatar
Member Avatar
+0 forum 1

I'm writing a program where the settings of a spreadsheet-like field of textboxes are changed using two for loops, and I can't for the life of me figure out why it's not working.I have tried declaring the txt variable and name variable in different orders using different methods, but nothing seems to work. With this code, I get the error, "Object reference not set to an instance of an object." Can somebody help me? Thank you. ' For loop repeats for each row For i As Integer = 1 To rows Step +1 ' Creates unicode character code for row …

Member Avatar
Member Avatar
+0 forum 16

I'm trying to iterate through the controls on a form and set the tabIndex to 0 for all labels. I copped the following code from google but it doesn't work for me and I'm pretty certain it's because all of my controls are on a panel and not on the form. Does anyone know how I can modify this code to work if the controls are on a panel. I've tried lots of things with no success. Private Sub setControls() Dim cControl as control For each cControl in me.controls If (Typeof cControl is Label) then cControl.tabIndex = 0 end if …

Member Avatar
Member Avatar
+0 forum 5

Good day folks. Problem: My program needs to import data from a database and display them in a table then manipulate and display the data in various ways. That bit is solved the next part is where I need help. The program then needs to save locally... 1. the newly processed data (what I mean is the data from the database plus all related data created by way of data manipulation). 2. the last view of the program? (What I mean is, when the program is restarted I want it to display the last thing the person saw; GUI and …

Member Avatar
Member Avatar
+0 forum 22

I'm trying to learn, understand and implement object-oriented PHP. Something's happening which I don't understand, and I would appreciate any guidance or help. I have the following class with the following properties and method: class Film { public $film_ids; public $numfilms; public function getFilms() { global $dbh; global $film_ids; global $numfilms; $film_ids = array(); new DBConnection; $sql = "SELECT * FROM films"; $stmt = $dbh->prepare($sql); if ($stmt->execute()) { while ($row = $stmt->fetch()) { $film_id = $row['film_id']; $film_ids[] = $film_id; } } $numfilms = count($film_ids); $dbh = NULL; } } "DBConnection" is a class that allows me to access a MySQL …

Member Avatar
Member Avatar
+0 forum 6

Hi, I am new to Java and is working on code in java which i need to keep a static sql script in property file and passing variable to it through java code and then iterating that property file to pass the variable value and writing that generated script to a text file in specific path producing a sql script. Can anyone help,its urgent.I am using eclipse hellios if that make a differnece. Thanks in advance!

Member Avatar
Member Avatar
+0 forum 1

Hello good day. I have a quick question is anyone able to assist me in saving a password file. I encrypted my password and so I want to save the salt and the encrypted password(which are byte arrays). I tried using a properties file, but I soon found out that I can't. Can anyone assist me in saving these byte arrays and retrieving them please?

Member Avatar
Member Avatar
+0 forum 5

Hi, I'm learning OOP and I'm having issue echoing an `attribute` function. This is my example: <?php class sandwich { function sandwich($hero) { echo "I like to eat $hero sandwich.<br>"; } } $a = new sandwich("roast beef"); $b = new sandwich("pastrami"); $c = new sandwich("turkey"); ?> When I echo it out: I like to eat roast beef sandwich. I like to eat pastrami sandwich. I like to eat turkey sandwich. Here is my `attribute function` with the same format: <?php class sandwich { var $attribute; function operation($hero) { $this->attribute = $hero; echo $this->attribute; } } $a = new sandwich("roast beef"); …

Member Avatar
Member Avatar
+0 forum 11

Rather than write a huge list of properties used by a class I want to know if I can dynamically generate them when needed. I have looked and __set and __get but I am not sure how (or if) I use them with what I am trying to do. The function I have at the moment is this (obviously doesn't work): public function getShowHelpingDetails($id) { $this->show_id = $id; $result = $this->selectRecord($this->table, $this->show_id, '*', '', 'show_'); foreach ($result as $key => $value) { $this->{$key} = $value; } } And then trying to access the properties like this: $h = new ShowHelping; …

Member Avatar
Member Avatar
+0 forum 8

How to use c sharp properties and after get value save in sql database.

Member Avatar
Member Avatar
+0 forum 4

Dear all, I am new to javascript.I have a little doubt in basic concepts in javascript. //Example Program class classname(){ //Decalaring Properties var length; var abcd; public function toUpperCase(){ //This Method is used to convert the strings into uppercase } public function toLowerCase(){ //This Method is used to convert the strings into LowerCase } } Point 1: Methods are the actions that can be performed on objects. var str="Hello world!"; document.write(str.toUpperCase()); Point 2: property is like variable (can able to set and get value at runtime.) I want to know how built-in-properties in javascript works? How "length" property works in …

Member Avatar
Member Avatar
+0 forum 1

Hello :) i found a need of properties in a Area class [CODE] public List<Tile> Tiles { get; set; } private int _goldValue; public int GoldValue { get { sum = 0; foreach (Tile t in Tiles) { sum += t.Surface.GoldValue; } return sum; } } [/CODE] well - something wierd... i didn't needed the private _goldValue.. actually i can delete it and everything will be just fine. am i missing something? the GoldValue public i want the Area's object will have - get it's value from the List of Tiles... 1. leave the private _goldValue just for the good …

Member Avatar
Member Avatar
+0 forum 1

Hello :) about the get set shortcut - [CODE]public int MyVar { get; set; }[/CODE] for example how it different from just: [CODE]public int MyVar; [/CODE]??? i heard that in the shortcut it add private myVar... huh?? if i can't see it how can i use it? when i use the previous system- [CODE] private int myVar; public int MyVar { get {return myVar;} set {myVar = value;} } [/CODE] i could use that to make things happen when i set the variable for example, like: [CODE] private int myVar; public int MyVar { get {return myVar;} set {MakeSomething(); myVar …

Member Avatar
Member Avatar
+0 forum 11

I have configuration properties implemented as a java.util.Properties Object with the mappings saved in a config.properties file. I have managed to update the properties in a user input panel, so the user can change any settings while the application is live. However I want any changes a user makes to be saved and be automatically set the next time the application is opened. Any ideas on how I can do this?

Member Avatar
Member Avatar
+0 forum 3

Hi all, been dipping my toe into OOP and am getting on OK, but I'm hitting a bit of a wall with a current project. classes: db (a PDO extended class) User Timetable The db is just a few shorthand ways of running PDO The User is just for handling the current user's details, e.g. profile etc. The Timetable is for showing the user's current timetable (and a few other things) I've currently got this thing going on in my page: [CODE]include("includes/config.php"); include("class/class.DB.php"); include("class/class.User.php"); include("class/class.Timetable.php"); $db = new db($config['db']); $u = new User($db); $t = new Timetable($db,$u);[/CODE] [COLOR="Red"]where I pass …

Member Avatar
Member Avatar
+0 forum 2

its been 6 days passed since i started making this assignment of mine it is to show how objectdatasource is used, until now, i still cannot getaway with this error, [B][U]The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content.[/U][/B] is anybody can help me? and check what is wrong with my codes? [CODE]<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div style="background-color: #FFCC00" > &nbsp;<asp:GridView …

Member Avatar
Member Avatar
+0 forum 4

Hello, it seems I am having some difficulties with my project in witch I am training my C# skills. Well, the problem is I have wrote the biggest part of the code, but I have problem to finish what i started, so I left blank code lines. Here is a link of the solution I am currently working on, if you have anytime, any additions to my code are welcome, you can e-mail me a new solution at : <email removed> I believe the comments are enough to help you understand what I am doing : [URL="https://rapidshare.com/files/459470853/Project_2011.rar"]https://rapidshare.com/files/459470853/Project_2011.rar[/URL] Thanks in advance.

Member Avatar
Member Avatar
+0 forum 1

Hi, im having trouble understanding how private methods are accessed, and overall how they are used. [CODE]using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SIT232_Ass1 { public class Plan { // declares constant private const int CHARGE_BLOCK = 30; // declates our private variables private decimal _MonthlyFee, _CallAllowance, _CallRate; //creates 3 read only properties public decimal MonthlyFee { get { return MonthlyFee; } } public decimal CallAllowance { get { return CallAllowance; } } public decimal CallRate { get { return CallRate; } } // custom or parameterised constructor - set the private with appropriate given parameter public Plan(decimal …

Member Avatar
Member Avatar
+0 forum 4

Hi! I have a question regarding a problem I've faced dealing with object oriented PHP. I'm used to always return a value after a method has been executed and then use the returned value in other methods. But that's because I've always done that in procedural programming. So I wonder if it's normal practice to instead use the properties of the class and use [B]$this[/B] to retrieve those values in the different methods instead of passing them as parameters? What is best and how should I do? code example. This: [CODE] class example { function __construct($param){ $result = $this->foo($param); $result2 …

Member Avatar
Member Avatar
+0 forum 2

Hi, I would like to know if its possible to edit a properties file after the project is deployed. I tried editing the values in the properties file using a classloader. [CODE] ClassLoader classLoader = this.getClass().getClassLoader(); prop.load(classLoader.getResourceAsStream("test.properties"));[/CODE] It reads the values properly but I couldn't write it back to the file. I used the following code to write the values back. [CODE] prop.setProperty("myValue", one); FileOutputStream outfile = new FileOutputStream("test.properties"); prop.store(outfile, null); outfile.close();[/CODE] The problem is that it stores/updates the file in bin directory of Tomcat. How can i use a relative path to edit and change the values of the …

Member Avatar
Member Avatar
+0 forum 5

i am using log4php for my logging in my development. is it possible to use 2 appenders on a single logfile? i wanted to have a daily logfile, thus wanted to use LoggerAppenderDailyfile that have properties also of rolling, thus needs the LoggerAppenderRollingFile. or if there is a way to configure the LoggerAppenderRollingFile to generate new log files everyday and can set the date(and format) as the filename , that would really be helpful. do you guys have any idea? thanks a lot, tinks

Member Avatar
Member Avatar
+0 forum 3

hi guys, just wondering is it possible to set all the textbox align to center within a form using just only one line of code? Rather than using [CODE] 123TextBox.TextAlign = HorizontalAlignment.Center 456TextBox.TextAlign = HorizontalAlignment.Center [/CODE] for every Textbox. Thanks.

Member Avatar
Member Avatar
+0 forum 2

Hy, I have a .properties file with a key-value defined like this: [icode]my_property.value=text text text bla bla bla {0} qwerty {1}.[/icode] I need to know what class should I use if I want to read the value and insert parameters in {0} and {1}. In the past I used to work with this, but I cannot remember what class I used to solve this. Thanks in advance! BR, end3r

Member Avatar
Member Avatar
+0 forum 7

HI why do we use get/ set to change properties? I mean instead of writing [CODE]class Point { double x, y; public Point(double x, double y) { this.x = x; this.y = y; } public double X { get { return x; } set { x = value; } } public double Y { get { return y; } set { y = value; } } }[/CODE] cant we write simply, supposse for eg, [CODE] x=5.0; y=x; [/CODE] please explain why do we need to use this get/set methoss?

Member Avatar
Member Avatar
+0 forum 6

As suggested by Duki in [URL="http://www.daniweb.com/forums/thread298488.html"]this thread[/URL] I figured I'd compile all the workable examples and explanations here towards the question of "Why do we use get/ set to change properties?" [QUOTE=pritesh2010]Properties provide the opportunity to protect a field in a class by reading and writing to it through the property. C# properties enable this type of protection while also letting you access the property just like it was a field. Becuase of get /set our class contains control over the input. let say E.g. if you don't need to use get/set. you colud write function for setfunct or getfunct …

Member Avatar
+2 forum 0

Hello... I have a composite control inside a repeater and I am trying to databind its properties like so (simplified example) : [CODE]<uc1:Control ID="id" runat="server" Value='<%# Eval("value") %>'>[/CODE] This works fine when I include the repeater inside a web user control, include that web user control inside ANOTHER web user control and then place the top level web user control onto a page - when I inspect the Value property inside of the composite control's EnsureChildControls() method that property's value is correctly set from the database. However, when I place my repeater with the composite control in it inside a …

Member Avatar
+0 forum 0

Hi, i need to read the database connection properties,driver class, username and password in java code...How can i read that using some properties....

Member Avatar
Member Avatar
+0 forum 1

hey guys, I`m a beginner in c# and I have a problem in using set/get in classes. actually I didn`t get why do we use them,can anyone please introduce them briefly for me?

Member Avatar
Member Avatar
+0 forum 7

The End.