I made a spell checker for a non-microsoft product that uses VBA by automating MS Word. Not a big deal really.
Where I am having trouble is the text to be checked comes from an editor that stores the text as html. Is there a tool I can use that will allow me to spell check the text minus the tags then join the text and tags back together? The editor needs the corrected html.
I rolled my own parser from scratch and it works, but fails on odd things such as a word where some characters in the word might be tag separated.
The following separates the tags from the text as an array of string.
If an item in the array doesn't start with "<" I spell check it and update the item in the array. After checking I rejoin all the items back into one string.
Code:
Private Function CleanList(ByVal sInput As String) As String()
Dim Segs1 As New Collection
Dim sList() As String
Dim sHold As String
Dim i As Integer
Dim c As String * 1
' Parse input to separate raw text from tags
For i = 1 To Len(sInput)
c = Mid$(sInput, i, 1)
If c = "<" Then
Segs1.Add sHold
sHold = "<"
ElseIf c = ">" Then
sHold = sHold & ">"
Segs1.Add sHold
sHold = ""
Else
sHold = sHold & c
End If
Next i
Segs1.Add sHold
Dim index As Integer
index = 0
' Join tags where no checking is needed
For i = 1 To Segs1.Count
If InStr(1, Segs1(i), "<Property Document") > 0 Then
ReDim Preserve sList(index)
sList(index) = Segs1(i) & Segs1(i + 1) & Segs1(i + 2)
index = index + 1
i = i + 2
ElseIf InStr(1, Segs1(i), "<StyleOverride Font='AIGDT'>") > 0 Then
ReDim Preserve sList(index)
sList(index) = Segs1(i) & Segs1(i + 1) & Segs1(i + 2)
index = index + 1
i = i + 2
Else
ReDim Preserve sList(index)
sList(index) = Segs1(i)
index = index + 1
End If
Next i
Set Segs1 = Nothing
'Return a cleaned up list
CleanList = sList
End Function
Hi I'm confused, my code is not working properly.
I really need your help guys.
I'm new with programming that's why I'm still having difficulties with this one.
What I want is the selected rows will be deleted(also in the database)
As you can see on the image above, I selected Fe and Maricon.
Once I click the delete button they should be deleted. But, that is not happening. No changes happened.
This is my database.
here's my code for the delete button.
Code:
For i = 1 To ApproverGrid.Rows - 1
If DeleteCell <> 0 Then
If Val(ApproverGrid.TextMatrix(i, 1)) = 1 Then
If MsgBox("Are you sure you want to delete the selected record?", vbQuestion + vbYesNo, "Confirm Delete") = vbYes Then
cn.Execute "DELETE FROM tbl_ApprovedBy WHERE ApproverName='" & Trim(ApproverGrid.TextMatrix(i, 1)) & "'"
MsgBox "The selected record has been deleted.", vbInformation + vbOKOnly, "Sucessfully Deleted"
update_display
Me.cmdAdd.Enabled = True
Me.cmdUpdate.Enabled = False
Me.cmdDelete.Enabled = False
Me.cmdCancel.Enabled = False
Me.cmdClose.Enabled = True
With ApproverGrid
.TextMatrix(0, 1) = ""
.ColWidth(2) = 4000
.ColWidth(0) = 0
.FixedAlignment(2) = flexAlignCenterCenter
End With
Else
MsgBox "No changes made!", vbInformation + vbOKOnly, "Message"
End If
End Sub
Code:
Function DeleteCell() As Integer
Dim i As Integer
For i = 1 To ApproverGrid.Rows - 1
If Val(ApproverGrid.TextMatrix(i, 1)) = 1 Then
DeleteCell = DeleteCell + 1
End If
Next
End Function
Code:
Private Sub ApproverGrid_Click()
On Error GoTo X:
With ApproverGrid
If Val(.TextMatrix(.Row, 1)) = 0 Then
.Cell(flexcpText, .Row, 1) = 1
Else
.Cell(flexcpText, .Row, 1) = 0
End If
End With
End Sub
Is there a way for a WebBrowser frame to refresh in the background and or when another frame is on top of that one.
Example:
I made a program that uses Timers to switch between 3 Web Browsers (frames) every 7.5 secs- The webpages are setup to auto fresh but none of the webpages update/fresh. I know I can force a refresh on the pages but then it will log me out of that page. What I am looking to do is still allow the pages to "refresh" or "update" when using multiple WebBrowsers on top of each other / not visible.
I know how to create MS Word Documents using VB6. I also use Access tables from which to pull data and then code in VB6 where those items may go in a Word Document. (Using MS Word 2013).
I also can create (manually) in MS Word (using the Developer Tab) Plain Text Content Controls, which allow someone to take the Word document and click on the control and type in the appropriate information.
What I would LIKE to do is, instead of using 'regular' Word docs, use a template I created to populate the Plain Text Content Controls directly with VB6 code, pulling from data in my Access tables.
Here is an example of a Word Document with editable Plain Text Content Controls (these are editable fields in the actual Word Doc, and shown in bold red below).
Any suggestions on how to know which Plain Text Content Control is which so I can 'fill' them programmatically, yet keep the controls editable if I send the Document to someone? My goal is to have pre-prepared (data already populated) EDITABLE documents (using the Plain Text Content Controls).
Quote:
Name (First and Last): Click to enter First and Last Name
Street Address/Apt: Enter Street Address.
City Enter City. State Choose a State. Zip: Enter Zip.
Home Phone: Enter Home Phone. Cell Phone: Enter Cell Phone.
Email Address: Enter Email Address.
Birth Date: Enter DOB. (Day Mon Year) Example: 12 Feb 1985
hi i am beginner in vb and i have a main form and many child forms. My main is maximized. i open a child form in main and it is also maximized but when i print the form using my printer with A4 size paper, the whole form covers the half of the page. How can i get the form height fit to the page and can i apply the scroll bar to the main form when it is already maximized. please help me also to take printpreview of the form.
What I am wanting to do make a program that will auto update out of date routers - I just need the part of the code to actually upload the file. All files will be named the same and be in the same File Path and the user will enter the router IP.
<blockquote>
<form method='post' ENCTYPE='multipart/form-data' action='upload.cgi' onSubmit='return isInProgress();'>
<!-- ZHONE_CUSTOM_MODS start -->
<b>Install New Software</b><br>
<!-- ZHONE_CUSTOM_MODS else
<b>Tools - Update Software</b><br>
ZHONE_CUSTOM_MODS end -->
<br>
<!-- ZHONE_CUSTOM_MODS start -->
NOTE: The update process takes several minutes to complete, and your Router will reboot.<br>
<!-- ZHONE_CUSTOM_MODS else
<b>Step 1:</b> Obtain an updated software image file from your ISP.<br>
<br>
<b>Step 2:</b> Enter the path to the image file location in the box below or
click the "Browse" button to locate the image file.<br>
<br>
<b>Step 3:</b> Click the "Update Software" button once to upload the new image
file.<br>
<br>
NOTE: The update process takes about 2 minutes to complete, and your Broadband Router
will reboot.<br>
ZHONE_CUSTOM_MODS end -->
<br>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>Software File Name:
</td>
<td><input type='file' name='filename' size='15'></td>
</tr>
</table>
<p align="center"><input type='submit' value='Update Software'></p>
</form>
</blockquote>
</body>
</html>
Sub NotepadIt(sTemp As String)
Dim daoTemp As DataObject
Set daoTemp = New DataObject
daoTemp.SetText sTemp
daoTemp.PutInClipboard
Set daoTemp = Nothing
Shell "notepad.exe", vbNormalFocus
SendKeys "^V", True
End Sub
The problem is DataObject, but I can't figure what's wrong. Perhaps I need to add a Reference?
Otherwise, can I change it somehow to have it working?
Thanks.
Is it possible to properly access a USB device with VB6?
I'm facing the daunting task of interfacing a VB program with a USB volume control device.
I've been all over the internet and have found enough information to list USB devices, obtain the full device name needed to use CreateFile to get handles for reading and writing. But I think I have reached either VB's or my limits or maybe both.
It's a rather simple device, turning the knob left sends a 1 and twisting it to the right and you get a 2. This all works without a problem.
Now I need to configure the device by sending data to a different End Point and that's got me completely lost.
Is it even possible to direct output to a different USB End Point with VB?
I found the following routine and added Shell32.dll as instructed
Code:
Private Function GetFolder(Prompt) As String
If shlShell Is Nothing Then
Set shlShell = New Shell32.Shell
End If
Set shlFolder = shlShell.BrowseForFolder(Me.hWnd, Prompt, BIF_RETURNONLYFSDIRS)
If Not shlFolder Is Nothing Then
GetFolder = CStr(shlFolder.Title)
End If
End Function
But it's failing on Me!hWnd. What is that ?
I presume that's something to do with a Form but I'm calling this from a module.
Can it be made to work anyhow ? Thanks
Ok, this is probably WAY over my abilities at the moment, but it's something I've been thinking about for a while. How could you make a program which could connect to a site and automatically get real-time weather data? Let's say I have a program or a game and I want it to simulate the actual weather in a location. I'm not sure where you would download the data from. In the US, would the National Weather Service or NOAA provide a way to do that, where your program could connect to their server and get weather information about a particular city? All I would need is just real basic information - the temperature and is it clear, or overcast or raining, etc. I know there must be a way because I've seen flight simulators to do this. I remember Microsoft Flight Simulator 2004 had an option where you could use real-time weather data, and wherever you were flying it would actually simulate the real life weather at that moment! I wouldn't need anything nearly that complicated, just basic weather conditions.
Does anyone have any suggestions? How hard would this be to do?
I keep getting that "can't open" clipboard error, although the clipboard is clear, Excel tells me the "clipboard is full", when the toolbar shows NOTHING, and the app that was using it, has closed.
Now I am not doing this in Excel, just was using that to take a look at the cb.
Anyone know how to release the clipboard beyond the clipboard.clear?
===
error 460 "invalid clipboard format", but this is not the error shown in msgbox from vb, which says "cannot open clipboard", but from this function:
'On Error Resume Next
'If optView(0).Value Then
'lstrText = VB.Clipboard.GetText(plngClipboardFormat)
'Else
'Set lobjPic = VB.Clipboard.GetData(plngClipboardFormat)
' End If
So something a little weirder than normal is going on. But what?
Just moved to Win 10 today (well, last night sometime before midnight). On Win7 and Win8.X I had no problem double-clicking on a .vbp file (in Windows Explorer) and opening it directly into VB6 (I didn't do anything 'special' other than associating the .vbp file with Visual Basic 6.0).
However, with my Win10 computer, it will not successfully open a .vbp file by double-clicking on it. It opens a copy of VB6, but then I get the "Error Accessing System Registry" prompt. When I create a shortcut (and set its default to Run as Administrator,) I can start VB6 okay, and then browse to, and successfully open, the .vbp file. Likewise, if I find the VB6.exe file and run IT as Administrator, I can open the file.
But I cannot simply double-click a .vbp file and have it open up with UAC permissions in VB6.
What am I missing? (Yeah, I Googled and Searched this forum, but failed....)
I just upgrade one of my desktop to Win10 Pro. I am very disappoint on the theme looking.
1. The window title is plain white
2. The control box (min/max/close buttons) only fill with either gray or red.
3. all triangle arrows (Scrollbar buttons,Combobox button) changed to plain arrow
4. the scroll bar thumb is a block in grey, how can so ugly?
...
I have to redesign my UI to cope with the changes!
No wonder MS is dying. He kill Nokia,now he kill himself.
I have developed an application which at times need to access some files from "Program Files" and Users folders on the system as well as a few hardware information.
To achieve this the user will have to close the software in midway and re-start by right clicking on it and selecting Run as Administrator.
This leaving work in midway and re-starting the software is irritating my users.
So how to self-elevate an application to a high privilege level?
Back in 2013 when I got a Win 8.X computer, I had issues attempting to install Service Pack 6.
Dilettante provided the correct link, and after downloading and running the .exe, it installed correctly.
However, now I have a Win10 machine (always seems like issues moving 'up'(??) with Microsoft Products) and when I download the Service Pack (see instruction below from dilettante that solved my 8.X SP6 installation) and run the .exe as Administrator, I get a notice that Service Pack 6 did not install correctly (and it didn't as it doesn't show up in the Control Panel, nor in the Help-About in VB6).
Notice the "d" suffix? This is because Microsoft actually does issue updates but they can't name them SP7, SP8, etc. because officially VB6 "is no longer supported." The changes should be very minor though and the important one was 6a which fixed some serious errors in plain 6.
Back in 2013 when I got a Win 8.X computer, I had issues attempting to install Service Pack 6.
Dilettante provided the correct link, and after downloading and running the .exe, it installed correctly.
However, now I have a Win10 machine (always seems like issues moving 'up'(??) with Microsoft Products) and when I download the Service Pack (see instruction below from dilettante that solved my 8.X SP6 installation) and run the .exe as Administrator, I get a notice that Service Pack 6 did not install correctly (and it didn't as it doesn't show up in the Control Panel, nor in the Help-About in VB6).
Notice the "d" suffix? This is because Microsoft actually does issue updates but they can't name them SP7, SP8, etc. because officially VB6 "is no longer supported." The changes should be very minor though and the important one was 6a which fixed some serious errors in plain 6.
Good day everyone , really need some help with this as I cannot find any solution and have tried everything already.
My problem comes when playing around with excel through vb, Im running sql queries and at the time of copying em to a workbook if I use copyfromrecordset its really slow, so I chose Querytables to do the job because it is faster, but Im getting an error when using it, heres my code.
Code:
Public Ora As ADODB.Connection
Public rs1 As ADODB.Recordset
Public SQL_STRING As String 'variable for the query
Public ExcelFile As Microsoft.Office.Interop.Excel.Application
Public ExcelWksht As Microsoft.Office.Interop.Excel.Worksheet
Public ExcelQueryTable As Microsoft.Office.Interop.Excel.QueryTables
Public ExcelRng As Microsoft.Office.Interop.Excel.Range
Something odd is going on here. I thought we'd figured this out.
Simple test case:
VB6 Form, one multiline Text1, one UserControl UC with no code written in it at all. DPI-Aware manifest.
Form has a Resize event handler that keeps Text1's position and width but sets Text1.Height = Scalemode, which works.
The Resize handler also tries to keep UC's position, but scale it to fit the rest of the Form. This works until I try DPI at 200% and then it does not resize to the full extent desired.
Some info is logged to Text1.
Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetClientRect Lib "user32" ( _
ByVal hWnd As Long, _
ByRef RECT As RECT) As Long
Private Declare Function IsProcessDPIAware Lib "user32" () As Boolean
Private Sub Log(Optional ByVal Text As String)
With Text1
.SelStart = &H7FFF
.SelText = Text & vbNewLine
End With
End Sub
Private Sub Form_Load()
Log "IsProcessDPIAware = " & CStr(IsProcessDPIAware())
Log "Screen.TwipsPerPixelX = " & CStr(Screen.TwipsPerPixelX)
Log "Screen.TwipsPerPixely = " & CStr(Screen.TwipsPerPixelY)
Log
End Sub
Private Sub Form_Resize()
Dim RECT As RECT
If WindowState <> vbMinimized Then
Text1.Height = ScaleHeight
With UC1
.Move .Left, .Top, ScaleWidth - .Left, ScaleHeight
End With
Log "ScaleWidth = " & CStr(ScaleWidth)
Log "ScaleHeight = " & CStr(ScaleHeight)
If GetClientRect(hWnd, RECT) Then
With RECT
'Ignore these two, always (0, 0) anyway:
'Log "ClientRect.Left = " & CStr(.Left)
'Log "ClientRect.Top = " & CStr(.Top)
Log "ClientRect.Right = " & CStr(.Right)
Log "ClientRect.Bottom = " & CStr(.Bottom)
Log "CalcScaleWidth = " & CStr(.Right * Screen.TwipsPerPixelX)
Log "CalcScaleHeight = " & CStr(.Bottom * Screen.TwipsPerPixelY)
End With
Else
Log "GetClientRect() err = " & CStr(Err.LastDllError)
End If
Log
End If
End Sub
At 100% DPI
At 200% DPI (reduced to save space here)
Any suggestions?
The Move method of a UserControl is already a pseudo-method that really belongs to the container (Form), and does not appear in the Object Browser even when you Show Hidden Members.
Also, replacing the instance of UC (UC1) with a PictureBox (Picture1) and using its Move method to fill the available Form space works just fine.