I am trying to set ≤ character into a VB6 Label.
Looking at https://en.wikipedia.org/wiki/List_of_Unicode_characters
The code would be 2264 .
Label.Text = Chr(2264) generates an error
Label.Text = ChrW$(2264) sets a question mark "?"
Does anyone know how to get this ≤ character
Label.Text = ChrW(&H2264) ' <-- &H for Hexadecimal
2264 is the Hexadecimal code, you can see it here.
In Decimal, it is ChrW(8804).
The stock Symbol font contains that symbol at an ansi codepoint and so works without requiring unicode awareness, as a contrived example with 3 autosizing labels:
lbl_left.Caption = "999"
lbl_middle.Font.Name = "Symbol"
lbl_middle.Caption = ChrW$(&HA3)
lbl_middle.Left = lbl_left.Left + lbl_left.Width + Me.TextWidth(" ")
lbl_right.Caption = "1000"
lbl_right.Left = lbl_middle.Left + lbl_middle.Width + Me.TextWidth(" ")
Related
so i'm trying to implement a simple english to farsi dictionary in iOS
i'd like to include both words in one table cell, problem is that english is L>R and farsi is R>L, also i'd like to make the farsi word a bit bigger.
I created an AttributedMutableString and I thought I put down all the correct values but it looks like there is a problem since it isn't rendering correctly.
code:
cell.textLabel?.numberOfLines = 0
var myString = "\(englishConvo[indexPath.row])\n\(farsiConvo[indexPath.row])"
var mutableString = NSMutableAttributedString()
var lenOfLang1 = englishConvo[indexPath.row].characters.count
var lenOfLang2 = farsiConvo[indexPath.row].characters.count
let increaseFontSize = UIFont(name: (cell.textLabel?.font.fontName)!, size: (cell.textLabel?.font?.pointSize)! + 5)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.Right
mutableString = NSMutableAttributedString(string: myString)
mutableString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: lenOfLang1 + 1, length: lenOfLang2))
mutableString.addAttribute(NSFontAttributeName, value: increaseFontSize!, range: NSRange(location: lenOfLang1 + 1, length: lenOfLang2))
cell.textLabel?.attributedText = mutableString
If i convert to a string using this code this is what I get
cell.textLabel?.text = String(mutableString)
Any thoughts / ideas would be super appreciated
Table cells already come with a layout that gives you two labels (text and detail), so why not just use it? Here, for example, in a language app of mine, I'm displaying a Latin word in the text label and an English translation in the detail label. You could easily do the same with Farsi and English.
I wanna make color selector, when picked color write color code to text box. I created color dialog and text boxes, how make a rgb and hex codes from picked color?
I'm trying this code, but it have a problem:
TextBox1.Text = ColorDialog1.Color.R + ", " + ColorDialog1.Color.G + ", " + ColorDialog1.Color.B
Getting:
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string ", " to type 'Double' is not valid.
Something like this will get you what you need...
Dim MyColor = Color.LightGreen
Dim R = MyColor.R
Dim G = MyColor.G
Dim B = MyColor.B
Dim HexString = String.Format("{0:X2}{1:X2}{2:X2}", R, G B)
Visual Basic is usually pretty accommodating when you try to combine numbers and text, automatically converting the number to a string to make the statement work. But the Color.R, G and B properties are a bit special, they are of type Byte. That type didn't exist in earlier versions of VB. They didn't add the automatic conversion.
Best thing to do here is to use the composite formatting feature supported by the String.Format() method:
With ColorDialog1.Color
Label1.Text = String.Format("{0}, {1}, {2}", .R, .G, .B)
End With
And for the hex version just change the formatting string:
Label1.Text = String.Format("#{0:x2}{1:x2}{2:x2}", .R, .G, .B)
I want to ask on how do to break the lines of arrays. I was making a questionnaire, when I encountered this. What I just want to do is literally just break the lines of the codes so that it won't be very long
I don't know where to start, so here is my first code:
Public Sub showQuestion()
Dim letter
Dim X As Integer
Dim Y As Integer
Randomize
question = Array("A programming language originally developed by James Gosling at Sun Microsystems", "A programming language from Microsoft", "Determines when the user wants to do something such as exit the application or begin printing", "Property information", "GUI information and private code")
answer = Array("Java", "Visual_Basic", "Command_Button", "Property_page", "Form")
question = Array("Specifies the background color of the control", "Generally, specifies whether or not a control has a border", "Determines whether or not the control can respond to user-generated events", "For controls displaying text, specifies the font (name, style, size, etc.) to be applied to the displayed text")
answer = Array("BackColor", "BorderStyle", "Enabled", "Font")
question = Array("Specifies the color of text or graphics to be displayed in the control", "Specifies the height of the control in pixels", "The string value used to refer to the control in code", "Specifies the graphic to be displayed in the control")
answer = Array("ForeColor", "Height", "Name", "Image")
qno = Int(Rnd * (UBound(question) + 1))
ReDim ans(Len(answer(qno)), 2)
lblquestion.Caption = question(qno)
For X = 0 To Len(answer(qno)) - 1
ans(X, 1) = Mid$(answer(qno), X + 1, 1)
Next X
For Y = 0 To Len(answer(qno)) - 1
If ans(Y, 1) = "_" Then
ans(Y, 2) = Chr$(32)
Else
ans(Y, 2) = "*"
End If
Next Y
loadHint
End Sub
Based on your clarification, you can break the line by using an underscore(_) something like this.
question = Array("A programming language originally developed by James Gosling at Sun Microsystems", _
"A programming language from Microsoft", _
"Determines when the user wants to do something such as exit the application or begin printing", _
"Property information", "GUI information and private code")
answer = Array("Java", "Visual_Basic", "Command_Button", _
"Property_page", "Form")
I want to add the lable box value in vb6
Label1 = 200
Label2 = 500
'Adding
Label3 = Label1 + Label2
'Showing output as
Label3 = 200500
I want add the 2 values
Expected Output
Label3 = 700
What was the problem in my code
Need code help
The two answers are correct, but neither of it explain to you why this happens. VB 6 (or 5 or 4 or 3) has a default property for the controls. In the case of the label, the default property is caption. Since caption is a string, and string can be concatenate using & or +, VB pickup the type and then it does the math (in this case, concat).
Label3= val(Label1) + val(Label2)
This works good.. Also you can use Cint or any other convert to number function.
long time haven't worked with VB6 but try
Label3.caption = val(Label1.caption) + val(Label2.caption)
Do something like this:-
textbox3.text = val(textbox1.text) + val(textbox2.text)
I'm trying to calculate the textWidth, but it seems to ignore the white spaces at the end. The text
"Hello"
"Hello "
returns the same text width. A string with " " returns 0. How do I calculate the width with the space?
You could always get the length of the string.
text.length
And then multiply that by how wide your characters are.
For example:
var aChar:String = "A";
var textWidth:int = (text.length) * (width of aChar);
Choose a terminator character, for Example "|".
Calculate Width(Text+Termainator)-Width(Terminator).