RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
vb.net行号 vb中行号是什么

vb.net中的问题

Message="未将对象引用设置到对象的实例。"

创新互联主要从事成都网站建设、网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务清流,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

Source="扫雷"

StackTrace:

在 WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\扫雷\扫雷\Form1.vb:行号 21

在 System.EventHandler.Invoke(Object sender, EventArgs e)

在 System.Windows.Forms.Form.OnLoad(EventArgs e)

在 System.Windows.Forms.Form.OnCreateControl()

在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

在 System.Windows.Forms.Control.CreateControl()

在 System.Windows.Forms.Control.WmShowWindow(Message m)

在 System.Windows.Forms.Control.WndProc(Message m)

在 System.Windows.Forms.ScrollableControl.WndProc(Message m)

在 System.Windows.Forms.ContainerControl.WndProc(Message m)

在 System.Windows.Forms.Form.WmShowWindow(Message m)

在 System.Windows.Forms.Form.WndProc(Message m)

在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message m)

在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message m)

在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

在 System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)

在 System.Windows.Forms.Control.SetVisibleCore(Boolean value)

在 System.Windows.Forms.Form.SetVisibleCore(Boolean value)

在 System.Windows.Forms.Control.set_Visible(Boolean value)

在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

在 System.Windows.Forms.Application.Run(ApplicationContext context)

在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()

在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

在 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)

在 WindowsApplication1.My.MyApplication.Main(String[] Args) 位置 17d14f5c-a337-4978-8281-53493378c1071.vb:行号 81

在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)

在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

在 System.Threading.ThreadHelper.ThreadStart()

VB.NET中,如何获得文本框中可见区域的首行的行号?

通过向文本框传递EM_LINEFROMCHAR消息可以得到光标所在的行号:

contst

EM_LINEFROMCHAR

=

0xC9

Dim

I

as

Long

I

=

SendMessage(textBox1.Hwnd,

EM_LINEFROMCHAR,

-1,

0)

VB.net怎么显示RichTextBox的行数、列数和总行数啊?

求行:

RichTextBox1.GetLineFromChar(RichTextBox1.SelStart)+1

这个代码呢,我的理解呢,是获取在selstart的地方的行数。一般来讲selstart的地方都是光标的地方,然后会给你返回line。不过返回的时候要自己加1。不是很懂这个语法,有懂得可以教我一下

以上是求行数。

求列:

For i = 0 To RichTextBox1.SelStart

If RichTextBox1.GetLineFromChar(RichTextBox1.SelStart) - RichTextBox1.GetLineFromChar(RichTextBox1.SelStart - i) 0 Then Exit For

j = j + 1

Next i

这个for循环呢,讲的是检查这一行光标前有多少个列,然后用J输出列的个数。

因为VB6.0没有RichTextBox1.GetFirstCharIndexOfCurrentLine这种语法。所以就得自己模拟这个过程。

具体怎么检查的呢,首先将 i 从0循环到光标处,

如果 【光标字符数】处的行数 减去 【光标字符数减去 i 个字符数】处的行数小于0了,我写了个不为零。但此时写小于零就可以。那么代表着换行了,同时也代表着光标到上一行之间有多少字。用j存储循环次数,得出对应列数。(我们中文习惯是叫第一列,但程序实际上是第零列,但在循环的时候就注意到并解决这个问题了)

如果你替换写法,例如

If RichTextBox1.GetLineFromChar(RichTextBox1.SelStart) - RichTextBox1.GetLineFromChar(RichTextBox1.SelStart + i) 0 Then Exit For

j = j + 1

Next i

这个 J 就对应着光标到该行结尾有几个字符了,如果有需要可以使用,但一般不需要。

那么就像上面说的那样,行列都求出来了,最后用事件和TEXT或者caption表现出来就好了

至于说总行数

RichTextBox1.GetLineFromChar(Len(RichTextBox1.Text)) + 1

通过对最后一个字符的位置(总长度)的行来判断呗,不过也得加一。


当前标题:vb.net行号 vb中行号是什么
URL链接:http://cqwzjz.cn/article/hjcgog.html