locked
Using New function RRS feed

  • Question

  • User743716020 posted

    Hi

    I got this statement

    objYieldCht.LegendBox.Font = New System.Drawing.Font("Arial", 6, Drawing.FontStyle.Regular)


    And I wanted to replace "System.Drawing.Font("Arial", 6, Drawing.FontStyle.Regular)" with a variable named fontName.

    objYieldCht.LegendBox.Font = New fontName


    So, I expected the assignment to be like the above code, but the compile saying fontName is not define? 

    How can I rewrite the statement?

    Thanks.

    Tuesday, December 15, 2009 2:32 AM

All replies

  • User711226119 posted

    First you sould declare the fontname variable as font then you have to define the value you needed and finall you can use that.

    Without declaring how you expect to use?

    Tuesday, December 15, 2009 2:56 AM
  • User743716020 posted

    This is what I got, how can I convert it to font?

    Dim LegendBoxFont As Font
    LegendBoxFont = CType(dtChart.Rows(0).Item("Chart_LegendBoxFont").ToString.Trim, Font)


    The second line failed as string cant be converted to font.


    Tuesday, December 15, 2009 3:10 AM
  • User-331346503 posted

    wht u sud do is

    dim fontName as New System.Drawing.Font("Arial", 6, Drawing.FontStyle.Regular)

    objYieldCht.LegendBox.Font = fontName


    Tuesday, December 15, 2009 3:19 AM
  • User743716020 posted

    Actually what I want is like this.

    I will keep the value of the font and color in database. Then I will retrieve it and convert it into font and color.

    Dim LegendBoxFont As Font  
    LegendBoxFont = CType(dtChart.Rows(0).Item("Chart_LegendBoxFont").ToString.Trim, Font)  


    So, I would convert the string to the type of font in this example, but how can I do it?

    Cos this method wont work.

    Tuesday, December 15, 2009 4:46 AM
  • User743716020 posted

    Actually what I want is like this.

    I will keep the value of the font and color in database. Then I will retrieve it and convert it into font and color.


    1. Dim LegendBoxFont As Font    
    2. LegendBoxFont = CType(dtChart.Rows(0).Item("Chart_LegendBoxFont").ToString.Trim, Font)    
    Dim LegendBoxFont As Font  
    LegendBoxFont = CType(dtChart.Rows(0).Item("Chart_LegendBoxFont").ToString.Trim, Font)  


    So, I would convert the string to the type of font in this example, but how can I do it?

    Cos this method wont work.


    I need some guide here, anyone can help?

    Tuesday, December 15, 2009 10:43 PM
  • User743716020 posted

    Actually what I want is like this.

    I will keep the value of the font and color in database. Then I will retrieve it and convert it into font and color.


    1. Dim LegendBoxFont As Font    
    2. LegendBoxFont = CType(dtChart.Rows(0).Item("Chart_LegendBoxFont").ToString.Trim, Font)    
    Dim LegendBoxFont As Font  
    LegendBoxFont = CType(dtChart.Rows(0).Item("Chart_LegendBoxFont").ToString.Trim, Font)  


    So, I would convert the string to the type of font in this example, but how can I do it?

    Cos this method wont work.


    Anyone can belp out?

    Sunday, December 20, 2009 8:01 PM
  • User711226119 posted

    HI, Go through this link as your reference...

    It might solve your problem..

    http://www.vbdotnetforums.com/windows-forms/13165-convert-string-system-font.html

    Regards!

    Wednesday, December 23, 2009 5:54 AM