คำตอบ visual basic questions

  • 16 เมษายน 2555 15:11
     
     

    Hi, I am taking my first programming course and we are using visual studios 2010. I had to create a text box to enter my name, followed by a box for my phone number, then 4 text boxes to change the color of my font. I also had to create a reset button which will clear all my text boxes. I have done all this without an issue, but my reset button only resets the name and number boxes, and will not reset the color boxes!!! My text is not too helpful with this problem. I have checked and rechecked all my codes to make sure everything is correct, but still cannot figure it out! Any help with the reset button would be greatly appreciated!

    Thank you!

ตอบทั้งหมด

  • 16 เมษายน 2555 15:25
     
     
    what is the syntax you are using to reset the color?
  • 16 เมษายน 2555 15:57
     
     คำตอบ มีโค้ด

    If you have to reset the color of a font, you need a default value to witch you set it, you cannot set it to nothing. 

    You can take the font of the form itself for instance.

    TheTextbox.Font = me.Font


    Success
    Cor

    • เสนอเป็นคำตอบโดย Jordan St. Godard 16 เมษายน 2555 20:06
    • ยกเลิกการนำเสนอเป็นคำตอบโดย elizod5 16 เมษายน 2555 20:09
    • ทำเครื่องหมายเป็นคำตอบโดย elizod5 16 เมษายน 2555 22:07
    •  
  • 16 เมษายน 2555 20:00
     
     

    ok, thank you! i actually have another question... i am having trouble programming my reset button on my mock window. i have it linked with a name bar and a phone number bar to display when i click my "display" button. when i click the reset button, the name bar and phone number bar clear, but my text box that they display on does not clear as it should. my textbook on visualbasics gave me a walk through but the codes do not seem to be working. my text box is set to "multi lines" but the only way i can get it to work is in a single line. do you have any tips?

    thank you!


    Liz

  • 16 เมษายน 2555 20:38
     
     คำตอบ มีโค้ด

    elizod5

    Try:

            TextBox1.Clear()
            TextBox2.Clear()

    Good Luck,
    • ทำเครื่องหมายเป็นคำตอบโดย elizod5 16 เมษายน 2555 22:20
    •  
  • 16 เมษายน 2555 21:01
     
     

    It is difficult to debug code that no-one has seen

    Post the code that you are using to clear the text boxes and someone may be able to identify what is wrong with it.

    It is not clear whether or not your first question has been answered.  You have commented 'thank you' and you have moved onto another question, but you then unproposed one response and didn't mark any other response as the answer!  Has the first question been answered or not?

  • 16 เมษายน 2555 22:30
     
     

    Yes, the question about the color boxes was answered and the reset button. enclosed will be my current code, I am using my text box called (DispalyBox) set to multi-line. to display the information, it is allowing me to enter and all the information, unfortunately now when I hit the display button, only the phone number will display in the display box.

    Public

    ClassForm1

    PrivateSubbtnDispaly_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesbtnDispaly.Click

    DispalyBox.Text = (TextBoxName.Text)

    DispalyBox.Text = (TextBoxPhone.Text)

    EndSub

    PrivateSubbtnBlack_CheckedChanged(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesbtnBlack.CheckedChanged

    IfbtnBlack.Checked = TrueThen

    DispalyBox.ForeColor =Color.Black

    ElseIfbtnRed.Checked = TrueThen

    DispalyBox.ForeColor =Color.Red

    ElseIfbtnGreen.Checked = TrueThen

    DispalyBox.ForeColor =Color.Green

    ElseIfbtnBlue.Checked = TrueThen

    DispalyBox.ForeColor =Color.Blue

    EndIf

    EndSub

    PrivateSubbtnExit_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesbtnExit.Click

    Me.Close()

    EndSub

    PrivateSubbtnReset_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesbtnReset.Click

    TextBoxName.Clear()

    TextBoxPhone.Clear()

    DispalyBox.Clear()

    EndSub

    PrivateSubbtnPrint_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesbtnPrint.Click

    PrintForm1.PrintAction = Printing.

    PrintAction.PrintToPreview

    PrintForm1.Print()

    EndSub

    PrivateSubMessageVisibleCheckBox_CheckedChanged(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesMessageVisibleCheckBox.CheckedChanged

    IfMessageVisibleCheckBox.Checked = TrueThen

    CDPictureBox1.Enabled =

    True

    Else

    CDPictureBox1.Enabled =False

    EndIf

    EndSub

    End Class


    Liz

  • 16 เมษายน 2555 23:48
     
     

    Liz,

    That’s a very pretty name; I hope that you don’t mind me saying so, but I think it is to the point that my daughter’s middle name is “Elizabeth”. Did you know that there’s a state in the U.S. whose namesake is based on that very name?

    That aside, I hope that you don’t mind that I make a few suggestions here.

    First, when answering a question directly, please make it obvious who you’re replying to; everyone here doesn’t see the forum in a threaded view and it’s not always evident. Either use the person’s name or quote them or something.

    Secondly, much though I despise how they’ve modified this forum in the last few weeks (you can tell that the people who administer the forum do NOT participate in it), please use the code block formatter when showing code. You can access that when you type out a message by clicking the button in the header that shows the “</>” glyph.

    Also, most people here are cautious when answering homework questions – certainly I am. Is this a homework assignment? It looks like it may be. There’s nothing wrong with that per se but most people here (me included) will attempt to answer a “homework question” differently than someone who develops on a regular basis.

    Lastly is this: Normally people will gripe when you extend the questions out beyond the original scope. The reason is simple – when others find it later by searching, it’s incongruent to see the thread start in one direction then divagate entirely into a new direction. I don’t think that’s too much the case here because it’s still all related to your original question but I did think it would be helpful to explain that.

    Good luck with your project!


    Please call me Frank :)

  • 17 เมษายน 2555 1:25
     
     คำตอบ

    I think this part of your code is wrong
    DispalyBox.Text = (TextBoxName.Text)
    DispalyBox.Text = (TextBoxPhone.Text)

    It should probably be
    DispalyBox.Text = (TextBoxName.Text)
    DispalyBox.Text &= " " & (TextBoxPhone.Text)

    or perhaps
    DispalyBox.Text = (TextBoxName.Text)
    DispalyBox.Text &= vbNewLine & (TextBoxPhone.Text)