How to setup custom expression in Blender?
If you want both A and B to be completely dynamic, without having a constant relationship between them, this requires a bit of work (otherwise a simple driver would suffice).

To get this to work, you need to define both properties in a propertyGroup, so that you'll be able to assign "B" with an "update function" - a function that is called whenever B's value changes.

That function then needs to parse your expression and assign the correct value back to B.

Here's the code for getting this to work:

bl_info = {
    "name"        : "Test",
    "author"      : "TLousky",
    "blender"     : (2, 74, 0),
    "version"     : (0, 0, 0, 1),
    "location"    : "3D View &gt; Toolbox",
    "description" : "Test 123",
    "category"    : "Test"
}

import bpy
import re

class samplePropertyGroup( bpy.types.PropertyGroup ):
    def update_b( self, context ):
        ''' Update function for property "B". This function is called whenever B's value is altered '''

        # Regular expression pattern for parsing the typed in expression:
        # (?:duration)? --&gt; The word "duration", which might or might not appear
        # (?:\s+)?(?:\+)?(?:\s+)? --&gt; The plus sign, which might exist or not, with or without spaces before or after
        # ([\d\.]+) --&gt; the actual numerical value in the expression, which could have a decimal point or not        
        pat = "(?:duration)?(?:\s+)?(?:\+)?(?:\s+)?([\d\.]+)"

        if "duration" in self.b:                # If the word "duration" exists in the manually assigned value
            m = re.match( pat, self.b )         # Then parse the string to extract the numerical value out of it
            if m:                               # And if parsing was successful
                numVal = float( m.groups()[0] ) # Get the value from the regex match object's capturing group
                self.b = str( self.duration + numVal ) # Then assign the value plus the duration prop's value back to "b"

    duration = bpy.props.FloatProperty(
        description = "This property is a simple float prop that doesn't support expressions",
        name = "duration" # Recommended not to use caps at the beginning of var names as a habit
    )

    # This one needs to be a string to be able to accept strings such as the other prop's name
    b = bpy.props.StringProperty( 
        description = "This property also accepts strings and might actually use them",
        name        = "b",
        update      = update_b # This is the important bit here, a reference to the update function
    )

class samplePanel(bpy.types.Panel):
    ''' Sample Panel '''
    bl_label       = "Sample Panel"
    bl_idname      = "sample_panel"
    bl_category    = "Test"
    bl_space_type  = 'VIEW_3D'
    bl_region_type = 'TOOLS'

    def draw(self, context):
        layout = self.layout
        col    = layout.column()

        P = context.scene.sample_props

        col.prop( P, "duration"      )
        col.prop( P, "b" )

def register():
    bpy.utils.register_module(__name__)
    bpy.types.Scene.sample_props = bpy.props.PointerProperty(
        type = samplePropertyGroup
    )

def unregister():
    bpy.utils.unregister_module(__name__)


You'll need to install this as an addon to test it, as it creates a new tab in the tools panel called "Test", where you will find both your properties.