Ken VB 0 Newbie Poster
Word2 =  "&" & Mid(ChoosenWord, PickedSeq(1), 1)
            Button2.text = "&" & Word2

this didnt work. same results with what i did. the ampersand (&) also displays. have any idea? please. help me.

Sorry - nothing is clicking for me on this one. Need to bring in the big guns. I suggest you repost the problems with a different title -
"Generating a keyboard shortcut at runtime" might get some other attention.
Good Luck.

Ken VB 0 Newbie Poster

That is cool. I made a hangman program for my daughter, and I used a loop to pull out each character into an array. ToCharArray would have been much better!

Ken VB 0 Newbie Poster

That is interesting - I have used isnumeric, and have seen try.parse, but when I took a class I was introduced to the try / catch block and have used that a lot.

In Buzzy's example above, wouldn't isnumeric miss a non-integer numeric entry (e.g. 15.4?) What would be an efficient way identify a decimal input?
As a hobbiest, I am not usually writing programs that would suffer from that sort of time penalty, but it is good to know! Thanks.

Ken VB 0 Newbie Poster

Here is the right answer!

For Each c In Me.Controls
            c.Font = New System.Drawing.Font("TimesNewRoman", 10)
        Next

You cannot have spaces in the font name, and you must show a font size. I tried it with just the Me.Font, and that did not work. I think you need to loop through the controls, or name each control on its own line.

I am curious as to why you are doing this? Is this to give the user some options on the appearance?

Ken VB 0 Newbie Poster

Are you trying to change the font on everything on the form? You might need to address each control individually. You could loop through each control:

Dim C as control
For each C in Me.Controls
C.Font = New System.Drawing.Font("Times New Roman")

Why are you doing this?

Ken VB 0 Newbie Poster

Got to try it - this works.

Try
            guess = Convert.ToInt32(textbox1.Text)
        Catch ex As Exception
            MsgBox("Invalid Input - not an integer")
        End Try
Ken VB 0 Newbie Poster

Maybe use a Try / Catch block:

Try
guess = Convert.ToInt32(txtGuess.Text)
Catch Ex as Exception
MessageBox.Show("Invalid Input")
End Try

I think that is the right format - I am not near the right computer to attempt. When you start a "Try" block much of the code generates automaticly.

Ken VB 0 Newbie Poster
TextBox1.Font = New System.Drawing.Font("Arial", 10)
Ken VB 0 Newbie Poster

I tried the same thing with this code: Button1.Text = "&" & "ButtonTest" - and it worked.
I wonder if the problem has something to do with the mid part of your code. What if you built a string variable first, like:

Word2 =  "&" & Mid(ChoosenWord, PickedSeq(1), 1)
Button2.text = "&" & Word2

Just grasping at straws here...

Ken VB 0 Newbie Poster

Hello SaintDK,

I would build a string like this: FileName = "C:\Program Files\Steam\Steamapps\" & userName.Text & "\Cstrike\CFG\" Then you just have to save FileName.

I hope that helps!

Ken VB 0 Newbie Poster

Dim cm As Integer
Dim m As Double
Integer.TryParse(TextBox1.Text, cm)
m = cm / 100
MsgBox(m)'This will display the value in your variable, not the "m."

You mean I have to follow this?

I'm not sure what the question is now.

If you are brand new at this, my recommendation is to start very simple. Create a form with just a textbox and a button. Put the code above into the click event of the button. Run the program, enter a value, and see what happens.

In your original code, it looks like you are not even sure how to start, so you need to start simple. This code:

If user enter integer then display = "m"

Is not real code, it is more like "here is what I want to do", so please start simple, and people here will help you build on that.

Good Luck!

Ken VB 0 Newbie Poster

After the login, try:

Mainform.Show
Ken VB 0 Newbie Poster

If user enter integer then
display = "m"


.

Your first problem is here. Don't put your variable in quotes, or you'll just display the "m". Try this to get started:

Dim cm As Integer
        Dim m As Double

        Integer.TryParse(TextBox1.Text, cm)
        m = cm / 100
        MsgBox(m)'This will display the value in your variable, not the "m."

Also, Integer.TryParse is only going to return a zero if the user does not enter an integer. Look at using integer.parse in a Try / Catch block to trap an invalid entry.

Ken VB 0 Newbie Poster

Hello OldQ,

I don't have a lot of experiance with graphics, but I think the problem is you put this in the paint event. Every time you click, it has to re-paint. Is there a reason you can't put this code in a button click event? Or, if you just intend to run it once, from the form_open event? Then it would run and stop after the 33 seconds.

This sounds very cool - how do you feed the temperature into the application?

Ken VB 0 Newbie Poster

yes, ur right again :) shit. i have to use yr code then ^^ lol, i never thought of testing with !@#$ etc

This will correctly test to make sure you only have letters - no numbers or symbols allowed.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim hold As String
        hold = Strings.Right(textbox1.Text.ToUpper, 1)
        If hold Like "[A-Z]" Then ' [!A-Z] would be use for "not in this set"
            MsgBox("its a letter")
        Else
            MsgBox("its not a letter")
        End If
    End Sub

I knew about this from creating a "hangman" game for may daughter - I had to make sure she didn't trick me by using numbers or hyphens! (Chris might think this is new-fangled!)

And Chris is right - you should also validate that the correct number of characters are entered, and be careful of upper and lower case!

Ken VB 0 Newbie Poster

Buzzy,

You need to declare your random number variable ONLY at the class level. When you declare a variable within a sub routine (Private Sub...), it is only accessible to that sub. You declared this at both the class, and again in the sub, so it reset to zero when you left the form load event and clicked your button.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        Dim random_number As Integer 'YOU ALREADY DECLARED THIS - DON'T DECLARE IT HERE OR IT WILL LOOSE IT'S VALUE WHEN YOU EXIT THIS PART OF THE CODE.       
Randomize()        
random_number = Int(20 * Rnd()) + 1

So, since you need to use this variable throughout your application, declare it at the class level (at the top), then assign it the random value as the form loads, then refer to it in the button click sub.

There are many important points to understand with variables. Try reading up on variable scope and life.

Good Luck!

Ken VB 0 Newbie Poster

Your not too far off the mark.
First, you are generating another random number every time you click your button. That makes it hard to win! Put the random number code in the load event of the form.
Next, you are going into and endless do loop - Once your loop begins, you cannot enter another guess. No need for a loop, just more to your If statement.
As you take this further, you will want to make sure the input is numeric.
Have fun!

Public Class Form1
    Dim randNum As Integer
    Dim guess As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Randomize()
        guess = Convert.ToInt32(txtGuess.Text)
        'Get Rid of the loop here
        If guess > randNum Then
            txtHint.Text = "Too High"
        ElseIf guess < randNum Then
            txtHint.Text = "Too Low"
        Else
            txtHint.Text = "Correct guess"
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put your random number generation here.
        randNum = Int(20 * Rnd()) + 1
    End Sub
End Class
Ken VB 0 Newbie Poster

I think line 3 could also be:
If achar [!A-Z] then

Ken VB 0 Newbie Poster

This goes into a messagebox, but could go into an label. Create a form with a textbox and a button. Enter a name into the form (must be more than one name, or you will get an array error). Click the button and get the messagebox.

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
Dim wholeName As String
        Dim name As String()
        Dim firstInitial As String
        Dim secondInitial As String

        wholeName = TextBox1.Text
        name = Strings.Split(wholeName)
        firstInitial = Strings.Left(name(0), 1)
        secondInitial = Strings.Left(name(1), 1)

        MsgBox(firstInitial & secondInitial)
    End Sub

End Class