I am unable to change my button text to "&" .
Button1.text = "&"
When I run the program button has no text.
What could be the problem ?
The "&" character is used to indicate short-cut keys.
To display the & itself, use it two times ("&&").
The problem is that & is used to make a keyboard Alt shortcut (eg. "&a" would make an Alt+a shortcut for that button), so you need to use two ampersands && and it should work.
Related
In Jupyter Notebook, you can toggle/comment a block of selected code with Ctrl + /, but this doesn't work in Google Colaboratory notebooks. Is there a way to comment out several lines of Python code easily in a Colaboratory notebook?
I've looked in the documentation, but I came up short.
In the default Colab keyboard shortcuts, you can block comment text using Ctrl+/.
If this does not work for you, check Tools->Keyboard Shortcuts and search for "Comment Current Line" to see what the shortcut is within your current settings.
You can select the lines of code and press (Ctrl + /) to comment or uncomment your selected lines of code.
You can also use triple single quotes (''') at the start and end of the code block you are interested to comment out.
''' ...Your commented code... '''
If you are a Mac user, you can use Command + / for commenting out, and if you want to uncomment again, select the lines and then Command + /.
For Mac users who don't have an American keyboard like me: it seems like Colab thinks you are using an American keyboard for shortcuts, and so to make the '/' character you have to press the second button to the right of the 'm'. I'll leave an image to explain.
My keyboard looks like this:
As I said, I have to press the . key to make '/' as if I were using an American keyboard.
For Mac users:
first select the lines that you want to comment
second push these buttons: Command + Ctrl + Shift + /
Especially in the Italian keyboard it would be: Command + Ctrl + Shift + 7 (because the "/" character is combined with button "7")
For some reason, I need to do Ctrl + Shift + :.
Which technically is Ctrl + /.
(I use an AZERTYUIOP keyboard.)
if you come here with an Italian keyboard you should press:
command + control + .
When using Mac the keyboard shortcut is ⌘+/.
Note that depending on your layout, / cannot be directly addressed and its combination is different when combined with ⌘. For example, on a German keyboard / is [Shift]+7 but the combination ⌘+/ is ⌘+[Shift]+ß.
When you are unsure about which combination is correct, use the inbuilt keyboard viewer which provides a live view of the meaning of keys while selecting modifiers.
Keyboard Viewer: default keyboard mapping
Keyboard Viewer: modifier keys keyboard mapping
I have a textbox, textbox1, whose ReadOnly property is set to true. It is somewhat like an on-screen keyboard. When the user presses a button, I can add characters by using:
Textbox1.Text = Textbox1.Text & A
But, when the user wants to remove the text, which should work exactly like the Backspace key, the last character should be removed from the textbox.
I am ready to give up normal textbox and use richtextbox if there is any way ahead with the rich one.
How to remove last character of a textbox with a button?
The previously suggested SubString method is what I would have posted too. However, there is an alternative. The Remove method works by removing every character after the given index. For instance:
TextBox1.Text = Textbox1.Text.Remove(TextBox1.Text.Length - 1)
You can use the SubString method to get all but the last character, for instance:
TextBox1.Text = TextBox1.Text.SubString(0, TextBox1.Text.Length - 1)
The above functions such as Substring and Remove are not executed in Visual Basic 6 (or earlier versions). I recommend to use Mid function.
For instance,in this example last character of Hello is deleted and rest of word is saved in Text1
Text1=Mid("Hello",1, Len("Hello") - 1)
and result is Text1=Hell
I am trying to add text to current text that is in a textbox using a checkbox. Once the checkbox is checked, it will "add" the text to the textbox before the text already in the textbox.
example:
if the textbox said "Jake", it would say "Hello Jake" once the checkbox was checked.
EDIT: sorry for the quick question. I'm in a hurry. But the only method I could think of was concatenating and appending text. As far as I know append() adds only to the end, and concatening isn't the logical approach. I don't have a coded example because I dont even know how to approach this issue. thanks.
It's getting a thumbs down because its so simple, but not. I'm using multiple checkboxes. So one needs to be in the very front, one in the center, etc. Each checkbox injects text into the textbox a certain way. I can do this with nested if statements, but then we got a mess.
Try using this code :
if chbHello.Checked then
txtName.Text = chbHello.Text + " " + txtName.Text
Note : if the checkbox is the trigger put this code in the checkbox.
All it does is see if the checkbox was checked or not.
When its checked just concatenate the text of the textbox and the checkbox with the
checkbox first.
I want to make bold just the "name" in the string, how to do it?
Dim name As String = Environment.UserName
LabelWelcome.Text = "Welcome " + name + ", ...!"
I don't believe this is do-able on default labels since there is no style formatting.
I suggest to use 2 labels or a rich text box control.
You can use two labels and put them side by side. One having the bold part and other having the simple text.
You can use the OnPaint() method for custom drawing also
I found this : http://pastebin.com/L4xScMjZ [Not made by me]
It's a class that highlights part of a label for you. It doesn't bold it, but you can highlight the important part in red or any color you want.
I'm sure you could turn this to make the highlighted part bold as well.
To use it, you create a new class and put that code in.
Build your project and there should be a new control called "Scrolling Label"
You can add that control to your project and edit the properties :
Highlight : # --> how many characters you want it to highlight from left to right
HighLightText --> The color of the highlighted text
This is a bit buggy so you might want to add "DoubleBuffer = True" in your form Load
For those who still Google this: You can make a function which replaces your characters with some unicodes. You can use most of WorksheetFunction.Unichar(119808) to WorksheetFunction.Unichar(120831)
Ok, I'm writing a program in vb. It's simply a text editor. However i've run into a little snag. My program has options to click a button and text is inserted into the text box. I am using this line:
textbox.AppendText (sometext)
Now this code works great if i want the text to be added at the bottom of the page. So here's my question, is there any way to modify or maybe replace this code so that the text is inserted were the cursor is?
Try setting .SelectedText property or using .Paste(String).
Not through the textbox control itself, as far as I know. You will need to use the SelectionStart property to manually insert the text.
textBox1.Text = textBox1.Text.Substring(0, textBox1.SelectionStart) & "INSERTEDTEXT" & textBox1.Text.Substring(textBox1.SelectionStart)
This is assuming you want to insert the text and not just replace it.