9 Replies - 331 Views - Last Post: 06 February 2018 - 04:43 AM Rate Topic: -----

#1 JessNutt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 18

visual studio - messagebox not returning textbox

Posted 05 February 2018 - 07:21 AM

I have a program which should put the content of two textboxes in variables then display the variables in message boxes. However even through there is text in the textboxes the message boxes still come up blank.

    Protected Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        Dim UserNameCheck As String
        Dim PasswordCheck As String
        UserNameCheck = Me.txtUsername.Text
        PasswordCheck = Me.txtPassword.Text
        MsgBox(UserNameCheck)
        MsgBox(PasswordCheck)
    End Sub 


Does anyone know what I have done wrong as I don't understand why the message boxes are displaying blanks?

Thanks,

JessNutt

This post has been edited by andrewsw: 05 February 2018 - 07:22 AM
Reason for edit:: removed VB.NET from topic title


Is This A Good Question/Topic? 0
  • +

Replies To: visual studio - messagebox not returning textbox

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • Joined: 12-June 08

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 07:39 AM

Put a break point on that event method, and step through it. Do the textboxes actually have values?
Was This Post Helpful? 0
  • +
  • -

#3 JessNutt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 18

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 07:48 AM

Hi Thank you for replying. Yes the textboxes have entries as I entered entries before selecting the button however when I step through it says they are blank
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • Joined: 12-June 08

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 07:52 AM

Are the textboxes on that actual form or another one?
Was This Post Helpful? 0
  • +
  • -

#5 JessNutt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 18

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 07:54 AM

The textboxes are on the actual form
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • RequestedRangeNotSatisfiable
  • member icon

Reputation: 6553
  • View blog
  • Posts: 26,566
  • Joined: 12-December 12

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 07:56 AM

You aren't mistaking them for two other textboxes are you? ;) Check their names in the Properties window.
Was This Post Helpful? 0
  • +
  • -

#7 JessNutt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 18

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 07:57 AM

I have double/triple checked the textbox names as there are only two textboxes and a button on the form
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14096
  • View blog
  • Posts: 56,495
  • Joined: 12-June 08

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 08:03 AM

From the information given it should work, but obviously there is something more than that snippet going on. I can plunk a textbox on a throw away form and a button and it works.
Was This Post Helpful? 0
  • +
  • -

#9 andrewsw   User is offline

  • RequestedRangeNotSatisfiable
  • member icon

Reputation: 6553
  • View blog
  • Posts: 26,566
  • Joined: 12-December 12

Re: visual studio - messagebox not returning textbox

Posted 05 February 2018 - 08:14 AM

Why is your Sub "Protected"?

You should also be using the .NET MessageBox, not the legacy VB6 MsgBox. MsgBox is something left over from a much earlier version of VB.
Was This Post Helpful? 0
  • +
  • -

#10 JessNutt   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-February 18

Re: visual studio - messagebox not returning textbox

Posted 06 February 2018 - 04:43 AM

Not sure what caused it but i recreated the form and it now works. Thank you to everyone who repsonded
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1