
图形界面
northwolves
MS-VB-MVP
MS-EXCEL-MVP
展开
-
菜单字体颜色可以更改吗?
一个简单的API语句可以实现更改菜单字体颜色:Private Declare Function SetSysColors Lib "user32" (ByVal nChanges As Long, lpSysColor As Long, lpColorvalues As Long) As LongPrivate Sub Form_Load() SetSysColors 1, 7, v原创 2004-02-01 23:16:00 · 1712 阅读 · 0 评论 -
Export selection of word document as an image file
原文地址:http://www.spotlight-wissen.de/archiv/message/1665077.htmlOption Explicit (c) Désirée und Wolfram, 3/2005 Modifiziert: 11/2007 - Bilder mit runden Ecken versehen Bilder aus Winword im转载 2008-10-25 15:43:00 · 1929 阅读 · 0 评论 -
Can the msgbox vbYesNo button captions be changed in VBA?
Private sButton1 As StringPrivate sButton2 As StringPrivate sCaption As StringPrivate sText As StringPrivate Const MB_ICONQUESTION As Long = &H20&Private Const MB_OKCANCEL As Long = &H1&Private Const转载 2007-12-06 00:31:00 · 3234 阅读 · 0 评论 -
Colour unique formulae and constant cells of all sheets of activeworkbook
A question in http://www.mrexcel.com/board2/viewtopic.php?t=304750I am looking for a macro which does two things: 1. colours all constants in a workbook as yellow. 2. colours all formulae with purpl原创 2007-12-06 00:16:00 · 1070 阅读 · 0 评论 -
Save an userform as an image in EXCEL
When click a commandbutton in an Excel userform,save the entire userform as an image file in harddisk.Method 1Private Declare Sub Keybd_Event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte,原创 2007-10-04 18:17:00 · 4182 阅读 · 0 评论 -
Adding checkbox to mshflexgrid
Private Sub MSHFlexGrid1_Click()If MSHFlexGrid1.Col = 0 Then MSHFlexGrid1.Text = Chr(124 - Asc(MSHFlexGrid1.Text))End SubPrivate Sub Form_Load() Dim i As LongWith MSHFlexGrid1.FixedCols = 0.Cols = 4原创 2007-10-04 02:11:00 · 1863 阅读 · 0 评论 -
VBA自动登陆163信箱
Sub Goto163()With CreateObject("InternetExplorer.Application").Visible = True.navigate "http://mail.163.com"Do Until .Readystate = 4DoEventsLoop.Document.Forms(0).All(9).Value = "myusername".Document原创 2007-10-01 18:22:00 · 14566 阅读 · 12 评论 -
n阶幻方的填法(n≥3)
幻方,亦称纵横图。台湾称为魔术方阵。将自然数1,2,3,……n*n排列成一个n*n方阵,使得每行、每列以及两对角线上的各个数之和都相等,等于n/2*(n*n+1),这样的方阵称为幻方。例如:把1,2,3,4,5,6,7,8,9填入3*3的格子,使得:每行、每列、两条对角线的和是15。 8 1转载 2007-09-23 11:16:00 · 13400 阅读 · 1 评论 -
VBA实现任意n阶幻方的一种填法(n≥3)
参考http://blog.youkuaiyun.com/northwolves/archive/2007/09/23/1796696.aspx的思路,拟代码如下:Sub magicsquare(ByVal n As Long, ByRef matrix())Dim i As Long, j As Long, k As Long, p As Long, a(), b()ReDim matrix(1 To原创 2007-09-23 21:56:00 · 2119 阅读 · 0 评论 -
The Number of Triangles Formed by Intersecting Diagonals of a Regular Polygon
Reproduced from http://www.cs.uwaterloo.ca/journals/JIS/sommars/newtriangle.html Journal of Integer Sequences, Vol. 1 (1998), Article 98.1.5The Number of Triangles Fo转载 2009-01-09 19:02:00 · 9384 阅读 · 0 评论 -
Ten Digit Powers
With helps of many friends, the Ten Digit Powers sequence has been updated to n=128. More details,see Ten digit numbers Millions thanks to 无心人,mathe and gxqcn. The sequence was showed as原创 2009-01-13 21:45:00 · 1062 阅读 · 0 评论 -
Select a table of certain webpage
Test the folowing codes,please: Sub Selecttable(ByVal url As String, ByVal n As Long) Dim t, r As Object, i As Long WebBrowser1.Navigate url, False Do While Sheet1.WebBrowser1.read原创 2009-10-27 19:34:00 · 1156 阅读 · 4 评论 -
VBA代码控制DTPicker控件的下拉日期表显示
DTPicker1控件的下拉按钮请问怎么写代码可以使得DTPicker控件的下拉日期表显示出来呢?!Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _(ByVal hWnd As Long, _ByVal wMsg As Long, _ByVal wParam As Long,原创 2009-11-05 21:25:00 · 6929 阅读 · 0 评论 -
Draw an egg(3)
Use 4 arcs to compose an egg shape:Private Sub Form_Click()Me.Caption = "Draw an egg"Dim pi As Single, X As Singlepi = 4 * Atn(1)Me.Scale (-2, -4)-(4, 4)Me.Circle (2, 0), 1, vbCyan, 3原创 2008-12-12 01:00:00 · 942 阅读 · 0 评论 -
Draw an egg(2)
Its also easy to draw an egg with the curve y^2=(sin(x)*(1+cos(x)/π)). Private Sub Form_Click()Me.Caption = "Draw an egg"Dim pi As Single, X As Singlepi = 4 * Atn(1)Me.Scale (-1, -2)-原创 2008-12-12 00:23:00 · 961 阅读 · 0 评论 -
Draw an egg
Its very easy to draw an egg with the curve y^2=(x^2-1)*(x-π)Private Sub Form_Click()Me.Caption = "Draw an egg"Dim X As DoubleMe.Scale (-1.5, -3)-(1.5, 3)For X = -1 To 1 Step 0.0005Me原创 2008-12-11 23:54:00 · 1095 阅读 · 0 评论 -
How Rich Are You in the World?
HOW RICH ARE YOU? Use the codes below ,you can find where you sit in the richest people list in world. Sub Showhowrichyouare()Getit InputBox("Please enter原创 2008-12-08 20:18:00 · 1634 阅读 · 0 评论 -
Draw a cube on Excel Worksheet
A cube is Composed of two squares and two parallelograms: Sub DrawCube() ActiveSheet.Shapes.AddShape(msoShapeParallelogram, [b2].Left, [b2].Top, 4 * [b2].Width, 4 * [b2].Height).Fill.Transpar原创 2009-02-03 21:49:00 · 1438 阅读 · 0 评论 -
vb分割三角形
题目要求:分割三角形的方法是从一个大的等边三角形开始,将其三边的中点进行连线,分成相同的四个三角形,除中间外的三个三角形再重复上述过程,直到满足给定条件的层次数为止.(原贴地址: http://topic.youkuaiyun.com/u/20081126/19/ea2362d5-613a-464d-8567-0ac64ca858a2.html) 模块代码:Type point原创 2008-11-27 09:32:00 · 1191 阅读 · 0 评论 -
应用API函数在用户窗体中画圆
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String)原创 2007-09-23 14:23:00 · 3301 阅读 · 0 评论 -
利用API 实现 字符串的镜像(二)
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc原创 2004-09-16 19:30:00 · 1604 阅读 · 0 评论 -
利用API 实现 字符串的镜像(一)
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc原创 2004-09-16 17:33:00 · 2361 阅读 · 1 评论 -
MSHFlexGrid1使用技巧(一)[如何让MSHFlexGrid只能被选中一行]
MSHFlexGrid控件点击时可以选中多行,但有时我们需要仅仅选中一行,有一个小技巧: Option ExplicitPrivate Sub Form_Load()Dim i As Integer, j As IntegerWith MSHFlexGrid1.Rows = 10.Cols = 4For i = 1 To 9.TextMatrix(i, 0) = "第 " & i & "原创 2004-09-02 22:35:00 · 3593 阅读 · 0 评论 -
动态裁剪窗体标题栏
本文演示了如何利用API进行窗体标题栏的裁剪和恢复,一并演示了控件的动态添加方法: This sample show you how to cut the caption title exactly and create controls with code.add a new form ,do nothing but copy this codes for it.Option Expli原创 2004-07-25 10:03:00 · 1735 阅读 · 1 评论 -
如何识别键盘左右的shift,Ctrl或Alt键
用API (GetAsyncKeyState)实现,在WIN 2K,XP 下有效:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As IntegerPrivate Const VK_LSHIFT = &HA0Private Const VK_RSHIFT = &HA1Private Con原创 2004-08-03 18:21:00 · 2733 阅读 · 0 评论 -
在场景中输出横向或纵向压缩的中文字符
今天参考一个外文代码写的:(作者:Steve McMahon steve@vbaccelerator.com, 网址: http://www.shitalshah.com/vbxlr/tips/vba0035.htm ) Private Const LF_FACESIZE = 32Private Const FW_NORMAL = 400Private Const F原创 2004-08-01 23:15:00 · 1719 阅读 · 2 评论 -
利用最小二乘法实现图片中多个点的一元线性回归
在日常生活和科学实验中,人们会经常发现因变量y和自变量x之间存在一定线性关系设一组数据为: 则y与x的关系可以用线性方程表示: 按最小二乘法可得: 线性关系的程度可以用相关系数r表示 所以,如果想在图象框中根据已知的多个存在线性关系的点描出相应的离原创 2004-07-31 22:03:00 · 3894 阅读 · 4 评论 -
API 更改系统菜单条目
一个运用API 更改系统菜单,复制系统菜单的例子。(需要注意的是:如果要响应菜单项的单击事件,可能要用到钩子函数和更多的代码)Option ExplicitPrivate Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVa原创 2004-02-02 23:31:00 · 2007 阅读 · 0 评论 -
MSHFlexGrid1使用技巧(二)[如何让MSHFlexGrid实现点击列标题排序]
Dim mysort As IntegerPrivate Sub Form_Load()With MSHFlexGrid1.Cols = 4.Rows = 20 20行4列For i = 0 To 79.TextArray(i) = IIf(i NextEnd Withmysort = 7 升序End SubPrivate Sub MSHFlexGrid1_MouseDown(Button原创 2005-08-30 00:17:00 · 3583 阅读 · 0 评论 -
两个Listbox的关联(省名 和 该省城市的对应)
Dim prov As New Collection Private Sub Form_Load() prov.Add "北京市,东城,西城,崇文,宣武,朝阳,丰台,石景山,海淀,门头沟,房山,通州,顺义,昌平,大兴,平谷,怀柔,密云,延庆", "北京" prov.Add "上海市,黄浦,卢湾,徐汇,长宁,静安,普陀,闸北,虹原创 2006-11-03 09:45:00 · 9388 阅读 · 0 评论 -
设置文本框的九种对齐方式(左上,中上,右上,左中,中中,右中,左下,中下,右下)
Add a commandbutton and a textbox( multiline=true) and copy the following codes to form1:Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Lo原创 2006-06-05 12:00:00 · 5114 阅读 · 0 评论 -
利用 wordXP 实现自动排班
许多工作岗位需要每天或每月排一次班,如何用WORD实现自动排班?笔者曾对此做过一些研究,不尽人意.在一位网友(chewinggum(口香糖·把减肥列入下一个五年计划) )提供了很不错的代码(http://community.youkuaiyun.com/Expert/topic/4304/4304006.xml?temp=.7863428),稍做了一些改动,感觉效果还可以.新建WORD文档,ALT+F原创 2006-05-07 18:35:00 · 3143 阅读 · 1 评论 -
不绑定记录集获取datagrid某行某列的内容
获取Dvatagrid第r行c列的内容可以用下面代码获得DataGrid1.Col = rDataGrid1.Row = cmsgbox DataGrid1.Text 但如果datagrid1中有滚动条,要得到滚动下面某行某列的内容时,系统会提示说:行号无效!这是由于DataGrid1.Row只能在[1,datagrid.visiblerows]间取值。当行号大于visibler原创 2006-05-10 09:23:00 · 2754 阅读 · 2 评论 -
关于DTPICKER 的 CHECKBOX
如果设置CheckBox属性=true时会出现一个复选框,这个框默认就是选定的,想调整成非选定状态,却不是很容易。Vb.net下稍简单一些dtp.value = nowdtp.checked = truedtp.checked = false但VB6没有CHECKED这个属性,笔者研究发现发送一个空格可以选定或取消选定:Private Sub Command1_Click()check DTPic原创 2005-12-18 10:06:00 · 3682 阅读 · 1 评论 -
我想死你了
在窗体上镂空文字: 我想死你了Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As LongPrivate Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As LongPrivate Declare Function PathToRegion原创 2005-11-12 00:48:00 · 2309 阅读 · 0 评论 -
如何在LISTBOX中移动鼠标就可以起到CLICK的作用
曾经看到有些软件能够实现这个效果,无非是向LISTBOX发送消息,获得光标所在位置的ITEM;或者干脆模拟一个鼠标左键的单击事件。下面用两种方法分别一试:方法1 Sendmessage 向LISTBOX发送消息Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, By原创 2005-11-17 23:07:00 · 2499 阅读 · 0 评论 -
VB获取网页下文字的链接地址
题目: 如何获取网页下文字的链接地址 窗口有WebBrowser1,和一个Text1 现在 Private Sub Form_Load() WebBrowser1.Navigate "http://www.baidu.com" End Sub 打开窗体显示百度的首页,要求滑动鼠标到“新闻”时 Text1里显示http://news.baidu.com/ 滑动到“帖吧”时 Text1里显原创 2009-11-24 21:31:00 · 3427 阅读 · 3 评论