Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Need help with VB


  • Please log in to reply

#1
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
This may sound like a stupid question, but I've looked everywhere and couldn't find the answer. How do you center something, like a textbox or button, in a form? And for it to remain centered when you maximize the program?
  • 0

Advertisements


#2
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
nevermind about this question, but I do have a new one. how do you make it so if you hit the Enter key (on your keyboard) an action will be done?

this is what I tried:

Private Sub vk_return_KeyDown()

Edited by stettybet0, 23 April 2006 - 05:51 PM.

  • 0

#3
Spike

Spike

    nOoB

  • Member
  • PipPipPipPip
  • 1,355 posts
Hey there stettybet0, sorry for the late reply.

Make a command button and set its properties so that "Defualt" is "true", put your coding in the command button. At runtime when you press enter it will automaticaly press the command buttone.

For Intrest sake: How To Set Exit Button.
Also you can use the "Esc" button on your keyboard to activate a button. Add a command button and set its "Cancel" property to "true" now when you press "Esc" the command button will be pressed.

Cool, I hope this worked for you. Let me know. Cool :whistling:
  • 0

#4
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
Hello Mr. Ramstein fan :whistling:,

to your first question: centering a control on a form has to be done manually, but its easy maths, so it should not be difficult. Subtract width of control from width of form and divide by two.

Your second question. Do this:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   If KeyCode = vbKeyReturn Then
	  ...
   End If
End Sub

  • 0

#5
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
Hai Mac's solution worked. I tryed yours spike hacker, but i dont know how to set the properties you talked about.
  • 0

#6
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
It's all in the Property window. Where you set the name for your controls etc. :whistling:

By the way, I wonder where you get those Geek In Training etc. ranks? Just out of interest :blink:
  • 0

#7
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
Well, I didn't see the properties he was talking about. And I just have a Button, not sure if that's the same as a Command Button... I use Microsoft Visual Basic 2005 Express, by the way.

And you get Geek In Training ranks by joining GeekU!
  • 0

#8
stettybet0

stettybet0

    Trusted Tech

  • Topic Starter
  • Technician
  • 2,579 posts
Okay, so now I am working to get my basic menu buttons working (New, Open, Save, Save As, Print, Print Preview, Cut, Copy, Edit, Select All) and i honestly have no idea. I almost got New (as in open a new window of my internet browser), but instead of opening a new window of my browser, it opens a window of Microsoft Internet Explorer...

Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
		WebBrowser1.Navigate("about:blank", "_blank")
	End Sub

Any help would be greatly appreciated... as would WHERE DID YOU FIND THIS INFO!?!?

Edited by stettybet0, 25 April 2006 - 02:31 PM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP