5 Replies - 380 Views - Last Post: 09 November 2019 - 12:44 PM Rate Topic: -----

Poll: NEWBIE HERE (0 member(s) have cast votes)

How can I display the result in Label or is there any tools that will display the result if they input a number?

  1. Label (0 votes [0.00%])

    Percentage of vote: 0.00%

  2. or what? (0 votes [0.00%])

    Percentage of vote: 0.00%

How can I show a string result. For example, they type a room number 202 which is found on 2nd floor, so the display sentence in the Label 1 is "The room (user's input which is 202) is on the second floor.

  1. Can I use a STRING (0 votes [0.00%])

    Percentage of vote: 0.00%

  2. or what? (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote

#1 iammrnotperfect   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-November 19

FIRST TIME USING VISUAL STUDIOS 2019

Posted 09 November 2019 - 09:13 AM

Public Class Form1

    Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress

        If (Not Char.IsControl(e.KeyChar) _
             AndAlso (Not Char.IsDigit(e.KeyChar) _
             AndAlso (e.KeyChar <> Microsoft.VisualBasic.ChrW(46)))) Then
            e.Handled = True
        End If

    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If TextBox1 = "" Then
            MessageBox.Show("Please input a number")
        ElseIf TextBox1 > 200 Then
            MessageBox.Show("Second floor")
        ElseIf TextBox1.Text < 100 Then
            MessageBox.Show("First floor")
        Else
            MessageBox.Show("The room does not exist")
        End If

    End Sub
    Private Sub Textbox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick
        TextBox1.Clear()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox1 = "" Then
            MessageBox.Show("Please input a number")
        ElseIf TextBox1.Text >= 100 To 120 Then
            MessageBox.Show("First floor")
        ElseIf TextBox1 >= 200 To 220 Then
            MessageBox.Show("Second floor")
        Else
            MessageBox.Show("The room does not exist")
        End If


    End Sub

    Private Sub Btn2_Click(sender As Object, e As EventArgs) Handles Btn2.Click
        TextBox1.Clear();
            Lbl1.Clear();
    End Sub
End Class
:code:

This post has been edited by modi123_1: 09 November 2019 - 12:38 PM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: FIRST TIME USING VISUAL STUDIOS 2019

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15363
  • View blog
  • Posts: 61,613
  • Joined: 12-June 08

Re: FIRST TIME USING VISUAL STUDIOS 2019

Posted 09 November 2019 - 09:57 AM

Yes, textboxes or labels.
Was This Post Helpful? 1
  • +
  • -

#3 iammrnotperfect   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-November 19

Re: FIRST TIME USING VISUAL STUDIOS 2019

Posted 09 November 2019 - 10:13 AM

If TextBox1 = "" Then
            MessageBox.Show("Please input a number")
        ElseIf TextBox1 >= 200 && <=220Then
            MessageBox.Show("Second floor")
        ElseIf TextBox1.Text >= 100 && <=120 Then
            MessageBox.Show("First floor")
        Else
            MessageBox.Show("The room does not exist")
        End If
:code:


HOW ABOUT THIS CODE? I'VE BEEN SEARCHING FOR THIS CODE IN GOOGLE BUT I DON'T KNOW HOW TO RUN THIS BECAUSE I
KNOW THAT THIS CODE IS WRONG. CAN YOU CORRECT MY CODE?


THAT IS MY IDEA. HOPE THAT YOU GET IT! I AM DOING MY PROGRAM FOR ALMOST 3 DAYS. CAN YOU HELP ME PLEASE? :(/>

This post has been edited by modi123_1: 09 November 2019 - 12:39 PM
Reason for edit:: In the future please use the [code] tag button in the editor

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15363
  • View blog
  • Posts: 61,613
  • Joined: 12-June 08

Re: FIRST TIME USING VISUAL STUDIOS 2019

Posted 09 November 2019 - 11:07 AM

First I should caution you that just mashing found code is not a good way to go. You should spend time learning the basics so you can write it yourself.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15363
  • View blog
  • Posts: 61,613
  • Joined: 12-June 08

Re: FIRST TIME USING VISUAL STUDIOS 2019

Posted 09 November 2019 - 11:36 AM

So a merry go pissoff for blowing up my Twitter DMs. Pretty darn rude.

If you have questions you post them here.

You should be trying to write the code and not asking folk to do it for you.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15363
  • View blog
  • Posts: 61,613
  • Joined: 12-June 08

Re: FIRST TIME USING VISUAL STUDIOS 2019

Posted 09 November 2019 - 12:44 PM

Quote

How can I display the result in Label


You assign a display value for a lable using the '.text'.

Ex:

MyLabel.text = "foo"


https://docs.microso...etframework-4.8



Quote

How can I show a string result.

Sounds like you should use the string function 'substring' which you can have return the first value in the string and use a SELECT-CASE statement to evaluate the value and pump out what ever string you want.

A SELECT-CASE is like a compact form of a series of IF-ELSEIF-ELSEs.

Additionally strings can be treated like an array so you can get the first value by looking at the 'zero index' of it.

https://docs.microso...g_System_Int32_

https://docs.microso...-case-statement

https://docs.microso...eatures/arrays/


Finally - it's better to put your questions in your post than making a weird poll for them.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1