PDA

View Full Version : Solved: Creating "At and Angle" Symbol in VBA



sam314159
03-16-2010, 11:41 AM
Hey guys, I need for my VBA macro to create a string that looks like this:

outputString = "12 /_ 90 o"

(Which reads twelve at an angle of 90 degrees in polar coordinates, incase what I typed didn't make sense)

Except that i need the /_ to be replaced with the actual angle symbol and the o to be replaced with the superscripted degree sign.

I did a good bit of googling and I figured out how I can do this in a userform caption using the "Symbol" font but I need to do this in my output string now.

Any ideas?

GTO
03-16-2010, 01:24 PM
For the degree sign, you should be able to use Chr(186)

Not sure on the angle sign, maybe look thru the various symbol fonts and see if anything is acceptable?

I tried this exceptionally cheesy ccode just to list what else might return, but didn't see anything close...

Sub ListChar()
Dim i As Long, j As Long
Dim ary(1 To 50000, 1 To 2)
For i = -32768 To 65535
If Not Asc(ChrW(i)) = 63 Then
j = j + 1
ary(j, 1) = ChrW(i)
ary(j, 2) = i
End If
Next

[A2].Resize(50000, 2).Value = ary

Beep
End Sub


Mark

sam314159
03-16-2010, 02:17 PM
Thanks Mark.

I just went through the list and I figured out that 272 produces Đ, which would actually be the angle symbol if font were set to 'Symbol'. I'm not sure if that helps me or not though.

mdmackillop
03-16-2010, 02:19 PM
If you have GDT font try

Sub Angle()
Data = Split(InputBox("Enter Number/Angle"), "/")
ActiveCell = Data(0) & Chr(130) & Data(1) & Chr(176)
With ActiveCell.Characters(Start:=Len(Data(0)) + 1, Length:=1).Font
.Name = "GDT"
End With
End Sub

sam314159
03-17-2010, 04:24 PM
Thanks MD, that worked perfectly in ActiveCell.

I tried to modify it so that it would work in a string like this:

txtBox.Value = "12 /_ 90 degrees"

But I couldn't figure that out. Can I set the font for part of textBox control like you did with ActiveCell?

Thanks again.

mdmackillop
03-18-2010, 02:41 AM
You can't use more than one format in a textbox, so if GDT has no numbers, you would need to find another font which has numbers and where the angle symbol has a code value less than 255.

Paul_Hossler
03-18-2010, 05:38 AM
Use Arial Unicode


Private Sub UserForm_Initialize()
With Me.TextBox1
.Font.Name = "@Arial Unicode MS"
.Font.Size = "10"
.Text = "12" & ChrW(8736) & "90" & ChrW(176)
End With
End Sub



Paul

mdmackillop
03-18-2010, 06:39 AM
Thanks Paul,
I've never used ChrW, so couldn't see how to code these extended characters.
Regards
MD

Paul_Hossler
03-18-2010, 07:09 AM
Useful tool

http://www.babelstone.co.uk/Software/BabelMap.html

Paul

lucas
03-18-2010, 07:28 AM
♫ I use:

http://www.tamasoft.co.jp/en/general-info/unicode-decimal.html

GTO
03-18-2010, 09:09 AM
:omg2: Gack! I never thought to try different fonts with them. Thanks for the nice info :thumb

Paul_Hossler
03-18-2010, 02:52 PM
Lucas --

Nice summary that shows the standard glyphs, but I didn't see how to select a font or view the Private Use Area (E000). Bablemap is more complicated, but the PUA varies between fonts so that's what I was looking for

For example, in Adobe Garamond Pro Italic, E000 is a Swash-A.

I need that kind of help when I'm looking for something :)


Paul

lucas
03-18-2010, 06:40 PM
Paul, I downloaded it and it's pretty nice. We use it for musical symbols a lot. ♬

The interface at the webpage I linked to only gives decimal. It's in grid format so you have to read from the left side and the column to get the numbers. The program you linked to will give you decimal or hex. Pretty handy.

sam314159
03-19-2010, 12:21 PM
Thanks for all the great helps guys.

lucas
03-19-2010, 12:31 PM
Sam, please mark your thread solved using the thread tools at the top of the page.

sam314159
03-19-2010, 12:37 PM
Sam, please mark your thread solved using the thread tools at the top of the page.

Done.

Do we have any kind of rep or feedback system on this forum? I looked around but couldn't find anything.

lucas
03-19-2010, 12:42 PM
You can rate the thread just to the right of thread tools.