Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Calculating Text Height Based On Font Size

I'm trying to size the height of a rich text box based on how many lines of text will be in the text box. I'm trying to find some way of calculating the expected height of the text as a whole. I was trying to do this by doing a ScaleY(BaseFontSize, vbPoints, vbTwips) * #of lines. This is not working. As I get more lines of text, the box begins to get too small. I already have a functon that determines the #of lines accutately. I am resorting to this method as the richtextbox does not appear to have any type of autosizing. Thanks

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Calculating Form's Height Based On List1.Height
On a Form I have a Listbox called List1.

As I resize the height of the Form I need it's height adjusted so that the height of the Listbox is always equal to Form1.Height - 1125.

Change Font Size Based On Length Of Text
i want it so that when someone enters something into a text box and push a button the font size of the text is decreased until the whole string is in the textbox and not going outside it.
so say someone enters into a text box "hello my name is blah blah blah"
not all of it will be visible because it goes beyond the length of the text box. i want the program to decrease the size of the text "hello my name is blah blah blah" until it fits into the text box. anyone help me out here ?

Finding Width/height Of A Character Based On The Assigned Font
If I have a Label which has been assigned a specific type of Font (ie: Ms San Serif, bold 8) then how can I find what the width twips/height twips of a display character would be based on the font used?


Setting Font Size According To Height

I have label with fixed height and width.

Ho to change font size to fit label's height?

Even more better it would be, if the code would change label's property multiline to true if text is very long.

Thanks for help.

Font Size Based On DPI
I have been scratching my head for awhile trying to come up with my own method to scale a form based on DPI settings. The end goal was to have my forms look exactly the same no matter what DPI setting the display properties are set to. The Left, Top, Width, and Height for controls were fairly straight forward. Then I had to determine how to calculate the font sizes. Below is the formula I came up with that seems fairly accurate. The main reason I am posting is maybe either to share this math with the VB community or to ask did I over complicate this and there was a magic setting that did this already.

BF = Base Font - Original size of the font when creating the form
CDPI = Current DPI setting - What is the video diplay currently set to the loop will just move to the next control
BDPI = Original DPI that the video display was set to when creating your form
X = The new font size to set your font to

BF - ((BF / CDPI) * (CDPI - BDPI)) = X

I have tested the above formula with a base of 96 DPI and it seams to scale very well when testing 120DPI, 144DPI, 192 DPI, 200 DPI and so on.

Sample Usage Code:

Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Const SmallFont = 96

Public Function ScreenFont() As Long
'Function to determine current DPI setting
Dim hwnd, hDC, logPix, r As Long
hwnd = GetDesktopWindow()
hDC = GetDC(hwnd)
logPix = GetDeviceCaps(hDC, LOGPIXELSX)
r = ReleaseDC(hwnd, hDC)
ScreenFont = logPix
End Function

Private Sub Form_Load()
Dim tmpI as Integer
On error resume next 'In case control does not have font property
For tmpI = 0 To me.Controls.Count - 1
'Change 96 to what the base DPI was when you created your form
me.Controls(tmpI).Font.Size = me.Controls(tmpI).Font.Size - ((me.Controls(tmpI).Font.Size / ScreenFont) * (ScreenFont - 96))
Next tmPI
End Sub

Calculating Text Height
I have a form that displays data in a picturebox. When data is present, the container for the data (a picturebox) resizes to hold all the data for scrolling. When the data is first loaded, I check the text height using the TextHeight method of the picturebox and adjust the height of the control. The problem I encounter is that the text height is not calculated correctly the first time. If I resize the control, it adjusts to the correct height.

'Private Subroutines and Functions

Private Function MoveFormControls() As Boolean
'Size and move the form controls.
'Recalculate the height of the data frame.
If (Not m_CurrentData.Landing) = -1 Then
'No data loaded.
Dim x As Single
Debug.Print picData.TextHeight("XX")
picData.Height = picData.TextHeight("XX") * (UBound(m_CurrentData.Landing) * 2 + 4)
End If

'More ....
End Function
The first time through, my cheesey method ("XX") returns 225 for the text height. When I resize, it returns 240 and the picture box is sized correctly. Is there a better method or does any one see a solution here?
I am initializing my font properties in the load event for the form.

Private Sub Form_Load()
'Set the startup properties for the form.
With Me
.Caption = App.ProductName
g_BorderWidth = (.Width - .ScaleWidth) / 2
Set .Font = mdlMain.g_Font
.Font.Name = mdlMain.g_Font.Name
.Font.Size = mdlMain.g_Font.Size
End With

Font Size In Relation To Number Of Pixels In Height???(*Resolved*)
Hi all

Does anyone here know exactly how many pixels on the x axis that say a 10pt font would use??

is 10pt 10 pixels??

Thanks in advance

Calculating Height Of Text Box At Run-time
I have a text box on a form which could have any number of rows of text in it.

I want to copy this text to another text box (which I can do), but how do I calculate the height the text box should be to fit exactly?

Do I somehow loop through the rows of text in the first text box?
If so how do I do this?


Change ListBox Width Based On Font Size
I have a ListBox displaying all ASCII characters. I let the user select the font size for the list box, but I would like to width of the ListBox to change based on that font size.

I thought of a cool way to find the width of the widest character in the font:

Have a label named Label1 on the page

VB Code:
...  Label1.AutoSize = True  widest = 0  For i = 33 to 255    Label1.Caption = Chr(i)    If Label1.Width > widest Then      widest = Label1.Width    End If  Next i  ...

EDIT: Submitted too early on accident

Then you could set the width of the ListBox to widest.

Anyway, some characters in Wingdings and such are VERY wide. So I'm not sure that I want the width to compensate for the widest one. I would perfer to make the width of the ListBox based on an average character. I am affraid to just grab the width of a random character using the method above, because it might be too small or too big.

Unless there is a good formula I could use to calculate average character width based just on font size I need a way to get the width of an average character. Any ideas?

Detecting The Current Font And Font Size On Various Lines In A Rich Text Box.
I have written an editor that uses a rich text box as the main text area.

The editor allows the user to select a font and font size on the toolbar.

My question is, how does one get the combo box text (for both the font and font size) to display the font or font size for the current line of the current character location?

Meaning, if I were to type in two lines, the first line being Arial 12pt, and the second line being Tahoma 14pt, how would I get the program to display the font and font size in the combo boxes?

I know about SelFont, SelStart and such, but I am not selecting any text. I am merely moving the cursor up or down and need to be able to display the font and font size for where the cursor currently is.

Anyone have any ideas?

I thank you in advance.

Detecting Font And Font Size On Various Lines In A Rich Text Box.
I have written a basic editor that uses fonts and such, however when I select a different line (while entering text into the text area of the rich text box), it doesn't display the font or font size for that particular location.

Does anyone have any ideas where I can look to solve this problem?

I thank you in advance for any information you may be able to share with me.

How To Get The Font Name And Font Size Of Header/footer Text?
Hi Everybody

Simple question.

In one of my procedures, I write the VBA Excel code set the text for headers and footer specifying the font name and font size (code line shown below in part).

'worksheetName has been previously defined to contain the
'name of the worksheet being handled
fullFilename = ActiveWorkbook.FullName
footerText = fullFilename & "[" & worksheetName & "]"
With ActiveSheet.PageSetup
.LeftFooter = "&""Times New Roman,Regular""&06" & footerText
End With

However, when I try to read the same (header/footer text) using code and assign it to a string variable, it actually includes the VBA code referring to the font name and font size as well. This is what I get (the contents of the string variable is shown below).

&"Times New Roman,Regular"&06H:MSOFFICEMY DOCUMENTSCombined National Monthly ReportTest11.xls[SBU - East]

Have a look at all the text prior to "H:..."

But when you see the header/footer content in pagesetup -> headers/footers, you only see the actual text viz :-

"H:MSOFFICEMY DOCUMENTSCombined National Monthly ReportTest11.xls[SBU - East]"

Is there a way to read this actual text only in to a string variable?

Best regards

Deepak Agarwal

Width And Height Of Text (at Certain Font) For Printing
I am printing text via the printer object and need to do calculations to figure out placement of this text.

Say I want to print "This is a test", in Arial 14 pt.

Is there an API that will tell me the width and height of that text? I need that to center it in a box.

I have already tried using a hidden label to figure out the width and height but that is cumbersome... there has to be an easier way!

DX7 DD Text Size/font
Is there a way to change the font and/or size of the text for the .DrawText property? If so, how?

Thanks in advance.

Font Size In Text Box
How can I change the text box size, according to the text written within, at runtime. To allow any size of text to fit the size of the text box.

Or is there a way of restricting the font sizes used from the font commondialog box at runtime.


Printer Font Size Vs Picturebox/form/font Size
HI Everibody.
Sorry for my bad English

Why the printer object font size is different as in Picturebox or form font size property?

I copyied in a PictureBox all the properties availabe in the printer object (width, height, scalemode, scalewidth, etc, etc) to simulate a printer object, but the font size in the picturebox is always greater therefore printer.currentX & Y does not match picture1.currentX & Y

Now, how can I configure a picturebox that matches perfectly the printer proportion? I need it to make Preview routine

How can I caculate the correct scale for Picture1?

Limit Length Of Text1.text Based On Size Of TextBox?
It's been a while since I've posted in these forums, though I'm still at work on Faux-INN, my VB online games network. If you'de like you can check it out at my website.

One of the most important aspects of Faux-INN is the way the interfaces are handled - for example, the bulletin boards look like real bulletin boards. Every player can build a custom 'avatar' that looks like they do, and when you're playing an opponent in Chess, you can actually *see* who you're playing with.

I've already added e-mail (which you can view by clicking on a 'post office'), but I want to make the input not look like a regular text box, but actually look like a page of a real letter; so you can only fit so much text on a given page.

I can subclass the textbox so it looks like a 'real' page; that's not the problem. My question is... if I have a textbox of a set size, can I put limits on the amount of text you can enter into the textbox, so that you can only enter as much text as could 'fit' in the box, without scrolling?

Thanks much!

Get All Text In A RTB To Be One Font And One Size (using .TextRTF)
I'm looking for a way to make sure all the text in my RTB is one font and one size. I was thinking of removing all "f1", "f2", etc. (1 meaning font #1 from the font table) but the "fs24" (font size) could be any number and I don't really want to do a loop of all possible font sizes from 0 - 99.

I guess I could use InStr to find all "fs" and then remove that and any numbers that follow it. I guess I was looking for an easier way to accomplish this. Like maybe just removing the font from the font table? I guess I would still have the problem with "fs" though...

Any thoughts?

I've got a MSFLEXGRID on a form...

Where does VB get the FONT SIZE for the TOOL TIP TEXT from?

Are there API calls that will allow me to make the FONT of the TOOL TIP bigger than the font of the MSFLEXGRID itself??

Rich Text Box Font Size...
How can I change it if I'm using a ShowFont dialog?


Change Output Text's Font Size
hi all,

i have a problem here.actually im developing a Normalization Tool using Vb 6.0. the main function of this tool is user can draw ERD using drawing toolbar and then this tool will help to narmalized it.for sure,user must input attributes for each entity when drawing ERD.

the entity's name and attribute's name will be appear on the notation of it possible if i wan to change the font size of attribute's name?and can give any ideas to do it?

thanks a lots..

Text Size And Font Names In Winspool.drv
hi all
following is the code useing in my application, when i direct the file to be prinited in fast way , its printing correct but i cant able print in bold letters and in different fonts, please help

Option Explicit
Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function EndDocPrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function EndPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (ByVal hPrinter As Long, ByVal level As Long, pDocInfo As DOC_INFO_1) As Long
Declare Function StartPagePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long
Declare Function WritePrinter Lib "winspool.drv" (ByVal hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, pcWritten As Long) As Long
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type

pDatatype As String
DesiredAccess As Long
End Type
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Public Sub OpenDocForPrint()
Dim strFileText As String
Dim intFile As Integer
Dim strTextToPrint As String
intFile = FreeFile
On Error GoTo Err_Trap
Open "C:p1" For Input As intFile
Do While Not EOF(intFile)
Line Input #intFile, strFileText
strTextToPrint = strTextToPrint & strFileText & vbCrLf
Close intFile
strTextToPrint = strTextToPrint & vbFormFeed
Call PrintThatFile(strTextToPrint)
Exit Sub
If Err.Number = "75" Then
ElseIf Err.Number = "53" Then
MsgBox "File Not Found", vbOKOnly, "Llamas Rule"
Exit Sub
MsgBox Err.Description, vbOKOnly, Err.Number
End If
End Sub
'Get default printer or use specified printer then spool and print
Public Sub PrintThatFile(strText As String, Optional strPrinter As Variant)
Dim lngPrnHndl As Long
Dim Written As Long
Dim strWrite As String
Dim typDOC As DOC_INFO_1
Dim lngCnt As Long
Dim lngFlen As Long
Dim strPrnName As String
Dim strReturn As String
Dim intReturn As Integer
If IsMissing(strPrinter) Then
strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", strReturn, Len(strReturn))
If intReturn Then
strPrnName = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
strPrnName = InputBox("No default Printer Listed, you must provide a Printer name", "Llama Print")
End If
strPrnName = strPrinter
End If
typDOC.pDocName = "Llama Printer"
typDOC.pOutputFile = vbNullString
typDOC.pDatatype = vbNullString
Call OpenPrinter(strPrnName, lngPrnHndl, PrnDef)
Call StartDocPrinter(lngPrnHndl, 1, typDOC)
Call StartPagePrinter(lngPrnHndl)
Call WritePrinter(lngPrnHndl, ByVal strText, Len(strText), Written)
Call EndPagePrinter(lngPrnHndl)
Call EndDocPrinter(lngPrnHndl)
Call ClosePrinter(lngPrnHndl)
End Sub


Richtextbox Text Changing Color When Font Size Changes

I have code to change the font size of the text in my Richtextbox, but when it does change the font size, it also changes the color of whatever the text currently is to black. In other words, if the text is currently red or blue, it will change the text to black.

combo1.additem "8"
combo1.additem "9"
combo1.additem "10"
combo1.additem "11"
combo1.additem "12"
combo1.listindex = 0

Private Sub Combo1_Click()
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.TextRTF)
RichTextBox1.Font.Size = Combo1.Text
End Sub

Anyone have any ideas why this might be happening ?


Changing The Font Size Of Text In A Cell In A PPT Table
How can I change the font size of text in a cell in a PowerPoint table?

Edited by - jeffers on 10/12/2004 10:39:49 AM

Changing Font Size In Text Mode Printing
Hi guys...

    I'm printing from my application in text mode. That is by using API functions such as OpenPrinter, StartDocPrinter, WritePrinter etc. My problem is that I need a better way to set the font size. At the moment I'm Doing it by appending chr$(15), chr$(18) etc before the string to be printed.
                   I just want to know whether there is any other better options to specify the font size.

I'm using VB 6.0 and Windows 98

Calculating Menu Height
Any idea how to determine the actual height of a popup menu at run time? I am trying to position a popup menu to the right of a text box making the middle of the menu exactly in the middle of the text box.

Locking The Font/size/style In Rich Text Boxes
Is there an easy way to force a single font on a rich text box so if someone pastes somehting in there it converts it back to the set font/size/style?

This Time Problem Setting Text Size And Font When Copying And Pasting.
I went to the VB newbie section and found something that looked like it would work until I realized I do not have VB 6.0 I have whatever it is that is with MS Office. I am attempting to copy my text from a text box change it to the font Courrier and size 11.

Need Help Calculating LoS In A 3D Tile Based Map
I have a 3D map 19x19x5 and I need to determine what can be seen and what is in shadow.

Whatever solution needs to be fast but perfect accuracy isn't vital (but would be nice hehe)

Essentially the LoS is for a squad-based CTBS game where the map is an isometric display using 2D tiles "stacked and offset" to create a Z coordinate the map loads in sections of 19x19x5 which is my "viewable area" I load a buffer of 1 segment around the active unit so a 3x3x3 array of mapsegs s'only 85k of ram so I figured what the heck eh?

At this time I have no idea how to do a good LoS routine... I can brute force one that's not very accurate by using a current tile to all other tile line check vs a sight blockage bitmap of the map... rather sluggish though. of course I can break off the check as soon as a block occurs and just toggle the viewmap for the portion of the line that met no obstacles... seems there should be a better way though.

Calculating A Value Based On A Range
Alright brain cramp

I have data returned in an excel format. Could have 25 rows or 250 rows of data some of which could have duplicate item numbers (part numbers) with what is on order and what is on demand (needed by customer). I need to determine what to Expedite, ie. what the ongoing total is for column 4 below depending on what Row I am analyzing.

Column      1 -- 2 -- 3 -- 4
Row    Part Number -- Demand -- On Order -- PO Line Qty
1     A -- 20 -- 10 -- 25
2     A -- 20 -- 10 -- 5
3     A -- 20    -- 10 -- 15
4     A -- 20    -- 10 -- 10

The result would be as follows:
Examining Row -- Result (Whats on Order)
1 -- 25
2 -- 30
3 -- 45
4 -- 55

When I run this code it does provide me with a sum'd value and walks nicely through to the end. However, the problem is that it's providing incorrect data. For example while examining row 1 it would return a value of 50.

Here is the Test sub that I am using to determine what lines to expedite. I would like to try and keep the code as small as possible. I've handled that on identifying duplicates, I don't remember what I used before to determine an ongoing value based on a range of cells.

Code:Private Sub test1()

        Row = intBegBordRow 'Beginning Row of a Border that is placed around a duplicate set
        Dim PoSum As Double
        Dim doneB As Boolean
        Dim target As Double
        Dim max As Double
        Dim ROP As Double
        Dim QOD As Double
        Dim QOH As Double
        PoSum = WorksheetFunction.Sum(Range(Cells(intBegBordRow, 22), Cells(Row, 22)))
        doneB = False
        QOH = Cells(intBegBordRow, 6) 'Physical On Hand Quantity of an Item
        max = Cells(intBegBordRow, 12) 'Maximum Stocking Level for an Item
        ROP = Cells(intBegBordRow, 13) 'Re-Order Point for an Item
        QOD = Cells(intBegBordRow, 7) 'Demand or Need from the Customer/s
        target = ((Cells(intBegBordRow, 7) + ((Cells(intBegBordRow, 12) + Cells(intBegBordRow, 13)) / 2)) - Abs(Cells(intBegBordRow, 6))) 'What target to bring an items On Hand quantity upto
         Do While Not doneB
            If Row = intEndBordRow Then
                doneB = True
                Row = intEndBordRow + 1
                If PoSum1 >= ((Cells(intBegBordRow, 7) + ((Cells(intBegBordRow, 12) + Cells(intBegBordRow, 13)) / 2)) - Abs(Cells(intBegBordRow, 6))) Then
                    Range(Cells(Row + 1, 1), Cells(intEndBordRow, 1)).ClearContents
                    doneB = True
                    Row = intEndBordRow + 1
     Row = Row + 1
                End If
            End If
    MsgBox "Variables: " & vbCr & _
            "intBegBordRow: " & intBegBordRow & vbCr & _
            "intEndBordRow: " & intEndBordRow & vbCr & _
            "intEndRow: " & intEndRow & vbCr & _
            "PoSum: " & PoSum & vbCr & _
            "Max: " & max & vbCr & _
            "ROP: " & ROP & vbCr & _
            "QOD: " & QOD & vbCr & _
            "Target((QOD+MidPt)-Max): " & target, vbOKCancel, "Integer Test"
End Sub

Any help or pointers would be greatly appreciated.


Changing Textbox Text Font Type/Size, Bold, Italic, Underline And Color
Hi everyone, this is urgent.

I have a textbox where user can type in there. When user select (highlight) the text they can change the font, size, Bold, Italic, Underline and/or color. It should work like in MS Word.

How do I do this? I have a combo box for Fonts, a combo box for Size, and 4 command buttons for B, I, U, and Color.

Please help?


Adjusting Form Size Based On The Screen Size
I want to Set My Vb 6.0 Form Size based on the Screen Width & Height. Its important that i should extend this to all the Controls in a particular form like ToolBar,Tree View, Grid etc.,

How to acheive this? I need the Solution as a reusable code which can be put in a Module (to be used when any form gets loaded).

Thx yaar ...

.. SK ..

Retain Font Styles When Changing Font Size
March 25, 2008

Re: VB6

Hello, everyone. I searched for over two hours for an answer but didn't find a relevant forum example. I am using a richtextbox for my documentation. I made several simple font features such as font sizes and font styles (bold and underline) to the richtextbox. The problem I have is that after I bolded and underlined some of my document text, if I change my document to a different font size, any text that have been bolded or underlined will be undone, so I have to highlight them and bold or underline them again. Does anyone have any advice or any example code to correct it?

The following is a fragment of code in selecting for fontbold and for changing font size:

If Len(Trim(RichTextBox1.SelText)) > 0 Then' For selecting text
RichTextBox1.SelFontSize = 14
End If
RichTextBox1.SelBold = Not (RichTextBox1.SelBold)' For selecting text for bold
RichTextBox1.Font.Size = 14 ' Font size to the whole document or richtextbox

Any advice or help will be greatly appreciated.


How To Change The Font Type And Font Size For A Menu Bar?
Dear all,
I meet a problem in my application. How can i change the font type and font size for the menu used in th form? Since my application is run on 1280x1024, it is too small to see the type on the menu bar. Could anyone help me? Very urgent!!! Thanks.


Changing Font Size And Bold And Font ???
dim Heading as string
Heading = "I want to Make this sentance Bold and bigger"

how would i go about making this variable bold and changing the font and font size.

Font Height ?
Hi guys,

Can you tell me how to determine the height of a font in pixel?

thank you

Calculating String Lenght Taking Font Into Account?
Hi all

Any suggestions how can I calculate the length of some string cocncerning in what font it will be printed out? What I need to do is to see if a string fits in a table cell and if not then manually split it into smaller pieces and manually insert these pieces in cells below and not let word do it and extend one row into more rows.

I hope you all understand what I wanted to say.

Thanks for the help.


Font Height And Width
Is there a way to retrieve the height and width (in pixels) of a font in visual basic???


Height && Font Properties
Using VB 6, mysql 4

Changing the height and font size of several buttons but some are not taking. The correct height and font size appear in the properties panel but when viewing, it's as if the properties were not change at all. Any reason why this may happen?

Calculating A Chunk Size
Hi, I'm creating a small tool that takes a chunk of data from a file, reverses the data and writes it to a new file, etc, until the end of the file.

This all works perfectly fine, but I don't want to hardcode the chunk size. I'd like to create a function that calculates a chunk size based on the total file size, but I'm not really sure how to do this.

For example, if the file size is above 5mb, the chunk size has to be between 40.000 bytes and 70.000 bytes

If a file is 32.471.657 bytes (30.9mb), then how can I calculate a number between 40000-70000 by using that file size?

Calculating Size Of Directory
I am attempting to calculate the size of a directory, plus and sub directory. I am using the following code. The problem is when it reaches a certain size, the result of the function then goes negative. Can someone tell what I is wrong?

VB Code:
Public Function GetDirectorySize(ByVal Root$) As Long' Function to calculate bytes used in Root$ and all subdirectories of Root$.' Root$ should be entered in the form c:Dir  Dim FData As WIN32_FIND_DATA  Dim fHand&  Dim sPath As String  Dim StillOK&  Dim ByteTotal As Long  Dim nPos As Integer  Dim DirName As String    sPath = Root$ + "*.*"  fHand& = FindFirstFile(sPath, FData)  If fHand& <= 0 Then    GetDirectorySize = 0    Exit Function  End If  ByteTotal = 0  Do    If (FData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then      nPos = InStr(FData.cFileName, Chr$(0))      DirName = Left$(FData.cFileName, nPos - 1)      If DirName <> "." And DirName <> ".." Then        ByteTotal = ByteTotal + GetDirectorySize(Root$ + "" + DirName)      End If    Else      ByteTotal = ByteTotal + FData.nFileSizeLow    End If    StillOK& = FindNextFile(fHand&, FData)  Loop Until StillOK = 0  fHand& = FindClose(fHand&)  GetDirectorySize = ByteTotalEnd Function

Calculating Size Of A Stretched Pixel
I'm using stretchblt to zoom in on a bitmap.

I'm trying to calculate how many pixels now make up what was once 1 pixel. Unfortunately, what I'm calculating and what StretchBlt is giving me are different. I don't have a good understanding of how StretchBlt works so maybe someone will see what I'm missing.

My example:

I'm selecting a box of pixels 20 X 20. I'm stretching it to 525 x 529.

So for my calculation of how many pixels will make up what was 1 pixel in the 20X20 image I used the following:

' NewPixWidth = OldWidth / NewWidth
26.25 = 525 / 20

However, when I look at the actual width that StretchBlt created a pixel is 25X25. This is causing me errors in my App because I am trying to calculate exactly which pixel of the unzoomed bitmap I'm on.

I think it is probably something in the way I'm calculating my new pixel width.

Does anyone have any ideas?

Font Type && Font Size

I was wondering what font type and font size you usually use in your vb projects.
What font size is too small, and what size is too big?
Do you use different fonts in your project? or maybe different font sizes?

As you noticed my question is some kind of a poll, I hope there will be much replies.

Thank you for your time!


Web Font Question: Font Size
has anyone by chance tried to figure out a way to convert font point size to html size?

Like FontSize @ 8 = HTML font size 1???


(I have figured out how to change web page settings on the fly...BG color...text color...ONLY for less complex pages)

Font Size Vs Font Selected?
I'm creating the editing toolbar for a Rich Text Box, and am starting work on the Font selector (combo) & Font Size selector (combo) and was wondering: Is the size dependant on the font chosen or can the font be any size the user chooses?

+--VB Dot Net
+-- Navman GPS Forums @

Font Size And Font Color
how do i let the user pick what font and what what color of a font with the common dialog?

Trying To Find The Height Of A String With The Current Font
I know there is an API to do exactly that, which is GetTextExtentPoint32, but I am trying to use it in a RichTextBox control. GetTextExtentPoint32 requires a hDc as its first argument, but the RichtTextBox does not expose an hDc property. I tried getting an hDc of the RTB using GetWindowDc which doesn't work. Well, it "works" meaning doesn't error, but it does not take the RTB's font into account when calculating the height of the string I pass to it, which is "H". I can improvise, setting the Font of the form to the same font as the RTB, and using the forms hDc to calculate font height, which works, but that is a very sloppy way of doing things. Is there anyway to make the RTB cough up its hDc?


Calculating Corect Frame Size Of MP3 File

I have got a file with this specification:

MPEG 2.5 Layer III
128 kbp/s (CBR)
8000 Hz, Mono
When using the following formula...

Frame Size = (144 * (BitRate * 1000) / Sampling Rate) + Padding
Frames = Audio Size / Frame Size
Duration = Frames / 27.8
...the duration is 1:12 (1/4 of the real length).
The real number of frames is 3973 and my program returns 1986. Therefore, something is wrong with

Frame Size = (144 * (BitRate * 1000) / Sampling Rate) + Padding
Thanks in advance!

Shift-jis &gt; Unicode &gt; Font Width/height(pixels) XD
hi, i need to know how i can convert a shift-jis string to a unicode string.
and also how can i find the width/height in pixels of each charecter (unicode (japenese))

please help im desperate ;P

Copyright 2005-08, All rights reserved