Plz help im very new to this


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Plz help im very new to this

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    5

    Plz help im very new to this

    Hello im really new to this, and I have a problem with some code. I need to make a form for users to enter two values to raise one number to a power, the calculator should use the exponential operator to calculate the result of raising the first number to the second.
    Here's what I got:

    'Calculate txtBase raised to 'x' power and display in lblResult
    lblResult.Text = Val(txtBase.Text) ^ txtExponent

    When I debug the program it says that there were build errors and it also says "Declaration Expected", It says that the problem is with "lblResult"

    This is my second program that I have ever made, I am an extreme beginner lol, Plz Plz Plz Help me!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Do you have a label on your form named lblResult? Also, labels do not have a .Text property; try changing it to lblResult.Caption.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2007
    Posts
    5

    im so lost :(

    I still can't get it I actually have a step by step guide but it doesn't say anything about errors, and I followed all of the steps correctly. Here's the steps:
    1.start visual studio 2005 and open a new project. save the project as exponent.
    2.use the textbox tool to insert two text boxes with one slightly above and to the right of the other one. the lower text box should be named txtBase, and the upper text box should be named txtExponent. change the text property for both text boxes to 0.
    3.use the label tool to add the label for the equal sign. it should be named lblEqual, and the caption should be the = sign. change the font size property to 14 point.
    4.use the label tool to add a blank label to the right of the equal sign. it should be named lblResult, and the caption should be deleted. the font should also be 14 point.
    5.add a Calculate button.
    6.give your form an appropriete title for the title bar.
    7.add code to the Calculate button so that the text value of the label named lblResult will contain the answer of the number entered for txtBase raised to the number entered for txtExponent.
    8.close the code window, start debugging the program, enter a value for the base (the lower text box) and a value for the exponent (the upper text box), and click Calculate.
    9.end the program.
    10.save your program and close the project.

    I did all of that right and I did it over about 10 times and its still the same.
    Plz help T_T

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    OK, first of all, you posted to the VB Classic forum, which is for questions about VB6 and earlier, so disregard my previous reply about the label's .Caption property. I have moved your question to the .NET forum.

    Try changing the code in your button's Click event to this:

    lblResult.Text = Val(txtBase.Text) ^ Val(txtExponent.Text)
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Apr 2007
    Posts
    5
    ?thats weird it still doesn't work?

  6. #6
    Join Date
    Mar 2005
    Location
    Los Angeles, Calif. AKA: Gangsta Yoda™
    Posts
    455
    What? Do you get any errors or messages?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer code questions via PMs.
    Microsoft MVP 2006-2009
    Office Development FAQ (VBA, VB6, VB.NET, C#)
    Software Engineer MCP (VB6 & .NET)
    Reps & Rating PostsVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6Outlook Global Address List

  7. #7
    Join Date
    Apr 2007
    Posts
    5
    yah it says that there were still build errors and they say that the declaration is expected, the only thing that I can think of is something in the properties went wrong but I can't find anything?

  8. #8
    Join Date
    Mar 2005
    Location
    Los Angeles, Calif. AKA: Gangsta Yoda™
    Posts
    455
    The previous code worked but I modified it to a more .net syntax. Val is a VB 6 carry-over. Its not bad but to learn .net you should use .net
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    	'Make sure each has something in them
    	If txtBase.Text.Length > 0 And txtExponent.Text.Length > 0 Then
    		lblResult.Text = CStr(CType(txtBase.Text, Double) ^ CType(txtExponent.Text, Double))
    	End If
    End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer code questions via PMs.
    Microsoft MVP 2006-2009
    Office Development FAQ (VBA, VB6, VB.NET, C#)
    Software Engineer MCP (VB6 & .NET)
    Reps & Rating PostsVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6Outlook Global Address List

  9. #9
    Join Date
    Apr 2007
    Posts
    5

    Talking

    Yay it worked thank you so much for helping me :P

Similar Threads

  1. Replies: 4
    Last Post: 11-24-2006, 08:25 AM
  2. Plz Urgent!! Its really essential
    By mr06 in forum .NET
    Replies: 2
    Last Post: 06-22-2006, 01:12 PM
  3. plz help me n00b here
    By Apocalyp5e in forum Java
    Replies: 11
    Last Post: 12-22-2005, 09:03 PM
  4. plz plz plz help me(java)
    By kamon in forum Java
    Replies: 4
    Last Post: 08-10-2005, 11:30 AM
  5. java applet... i'm in a fix, plz help
    By nsbscool in forum Java
    Replies: 1
    Last Post: 05-02-2005, 09:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center