I am developing new vb 6 application, I want to display a scrolling text (marquee)
on a status bar like news Line text I already have two panels used and now in the
third panel I want to use marquee.
I have done following but text is scrolling from middle of the panel it should be
scrolled from the right end to left end continuously.
Dim i As Byte
dim txtSample As String
txtSample = " - - - MARQUEE TEXT - - - "
Private Sub Timer1_Timer()
i = i + 1
StatusBar1.Panels(3).Text = Mid(txtSample, i)
If i > Len(txtSample) Then i = 1
End Sub
You code is actually correct but you are actually reducing the content in a rapid manner makes it a marquee. So to make it start from far edge instead from the length of your string, you have to buffer your string with space to cover the whole panel visible area.. something like this should do
txtSample = Space(150) & "- - - MARQUEE TEXT - - - "
Related
I'm writing a program in visual basic 2015 to add users to the school server. I have text box's, that aren't editable, to display input from other text boxes. Sounds more complicated than it is, but the text boxes simply show your entries, so a lot will be completed without having to double up on entries. As the input changes on an input textbox, it updates to the display. However, I cannot detect a backspace input to update the displayed content. Is there a way to do this?
Here's a sample of the code.
Private Sub dp_TextChanged(sender As Object, e As EventArgs) Handles dp.TextChanged
If dp.Text = "" Then GoTo line1
i = Asc(dp.Text)
If i = 8 Then
domainp.Text = domainp.Text.Remove(domainp.Text.Length - 1)
End If
If dp.Text = "" Or dp.Text = " " Or dp.Text = "." Then GoTo line1
domainp.Text = domainp.Text & dp.Text
domain_prefix = domainp.Text
dp.Text = ""
i = 0
line1:
End Sub
I haven't programmed for years and have forgotten a LOT of things. I would appreciate any help you could give me.
I am using visual studio 2015
Use the KeyDown event. This will capture any type, backspace, or arrow key movement.
I've created a program that is fully functional and I have sent it to some clients. Some of them have really old computers with really low resolution and they can't access it easily since the form and the controls are oversized for them. Is there an easy way for me to make it to automatically resize both form and controls according to the resolution?
As I've said in the title, this is for Visual Basic 6.0. Thanks to all of you in advance.
You can store size and location of each control on the form, and move or resize controls according to your needs.
In the code below, I use "TabIndex" property as unique id for each control (I can't remember in my old VB6 memory if that's the right thing to do...).
I store the size of the form, and the size and location of each control in the Form_Load event.
Private lWidth As Long
Private lHeight As Long
Private Enum ePROPERTY
ep_Top = 0
ep_Left = 1
ep_Width = 2
ep_Height = 3
End Enum
Private aControlSize() As Long
Private Sub Form_Load()
Dim ctlTmp As Control
lWidth = Me.Width
lHeight = Me.Height
ReDim aControlSize(3, Form1.Controls.Count)
For Each ctlTmp In Form1.Controls
aControlSize(ctlTmp.TabIndex, ep_Top) = ctlTmp.Top
aControlSize(ctlTmp.TabIndex, ep_Left) = ctlTmp.Left
aControlSize(ctlTmp.TabIndex, ep_Width) = ctlTmp.Width
aControlSize(ctlTmp.TabIndex, ep_Height) = ctlTmp.Height
Next
End Sub
Then each time the form is resized (Form_resize event), you'll have to move or resize each control.
Some of them need to be anchored to the right or to the bottom (or both). Some need to be resized and moved. Others don't need nothing.
Private Sub Form_Resize()
Dim ctlTmp As Control
For Each ctlTmp In Form1.Controls
Select Case LCase$(ctlTmp.Name)
Case "text1"
' Text1 is anchored to the left and right borders of the form :
ctlTmp.Width = Me.Width - (lWidth - aControlSize(ctlTmp.TabIndex, ep_Width))
Case "command1"
' Command1 is anchored to the right border of the form :
ctlTmp.Left = aControlSize(ctlTmp.TabIndex, ep_Left) - (lWidth - Me.Width)
Case "check1"
' check1 is anchored to the bottom border of the form :
ctlTmp.Top = aControlSize(ctlTmp.TabIndex, ep_Top) - (lHeight - Me.Height)
End Select
Next
End Sub
Form loaded :
Form Resized :
Please be advised that my code is largely perfectible...
There's probably a more elegant solution that goes through overload each Control and to add properties/methods like the existing ones in dotnet.
I'm looking to have my excel sheet with a split in it (vertically) ensuring a set of controls stay on the left of the screen for easy access. Currently Im using this code to select and move to a cell, based on a list of headings I have in the A column.
Option Explicit
Dim trimProcess() As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer
If Not Intersect(ActiveCell, Range("A6:A1000")) Is Nothing Then
If ActiveCell.Value <> "" Then
For i = 0 To UBound(trimProcess)
If ActiveCell.Value = trimProcess(i) Then
Cells(4, 4 * (i + 1)).Select
Cells(4, 4 * (i + 1)).Activate
End If
Next
End If
End If
End Sub
This works fine for what I need, but it only works in the active split view IE if I click a cell in A in the left split, it moves the left split view. I want it so that the changes only the right view, but cant find the code to do so. Is this possible?
I have many power point slides and each slide has many lines but all those lines are in the same objects. I want now to add some animation including appears for each line with click.
How I can partition the lines in each slide such that every line will be in its own object
Note, I am using powerpoint 2010
Thanks,
AA
This isn't perfect; you'll need to add more code to pick up ALL of the formatting from the original text, but it's a start. Click within the text box you want to modify, then run the TEST sub. Once it's adjusted to your taste, it's a fairly simple matter to extend it to act on every text box in the entire presentation (though not tables, charts, smartart, stuff like that)
Sub Test()
TextBoxToLines ActiveWindow.Selection.ShapeRange(1)
End Sub
Sub TextBoxToLines(oSh As Shape)
Dim oSl As Slide
Dim oNewShape As Shape
Dim oRng As TextRange
Dim x As Long
With oSh
Set oSl = .Parent
With .TextFrame.TextRange
For x = 1 To .Paragraphs.Count
Set oRng = .Paragraphs(x)
Set oNewShape = oSl.Shapes.AddTextbox(msoTextOrientationHorizontal, _
oRng.BoundLeft, oRng.BoundTop, oRng.BoundWidth, oRng.BoundHeight)
With oNewShape
.TextFrame.AutoSize = ppAutoSizeNone
.Left = oRng.BoundLeft
.Top = oRng.BoundTop
.Width = oSh.Width
.Height = oSh.Height
With .TextFrame.TextRange
.Text = oRng.Text
.Font.Name = oRng.Font.Name
.Font.Size = oRng.Font.Size
' etc ... pick up any other font formatting you need
' from oRng, which represents the current paragraph of
' the original text
' Bullets, tabs, etc.
End With
End With
Next
End With
End With
oSh.Delete
End Sub
I am writing a programme to be used internaly within our company and have come across the problem below:
How can you get a Child form to centre on the screen when using the MDI parent maximised form as the backgroung
In the MDI child screen, create a Form_Initialize function like this:
Private Sub Form_Initialize()
Me.Left = (MDIForm1.ScaleWidth - Me.Width) / 2
Me.Top = (MDIForm1.ScaleHeight - Me.Height) / 2
End Sub
Of course, you'll need to substitute the name of your MDI form where you see MDIForm1 in the code above.
From Microsoft:
"The initial size and placement of MDI child forms are controlled by the Microsoft Windows operating environment unless you specifically set them in the Load event procedure."
From the parent:
Private Sub MDIForm_Load()
CenterChildForm MDIForm1, Form1
End Sub
Sub CenterChildForm(Parent As Form, Child As Form)
If Parent.WindowState = 1 Then Exit Sub 'The Parent is minimized, centering is invalid.
Child.Top = (Parent.ScaleHeight - Child.Height) / 2
Child.Left = (Parent.ScaleWidth - Child.Width) / 2
End Sub
From the Child:
Private Sub Form_Load()
Me.Left = (MDIForm1.ScaleWidth - Me.Width) / 2
Me.Top = (MDIForm1.ScaleHeight - Me.Height) / 2
End Sub
Select from the properties in the IDE on the bottom right the WINDOWS PROPERTY - CENTER PARENT. It may be named something a little difference but is in the drop down with CENTER SCREEN
EDIT: I think it is WINDOWS POSITION - CENTER PARENT
As an addition to the above use the me.Move [left], [top], [width], [height] method
it is quicker and performs the positioning in a single action.